构建DateTime对象为SQL数据库插入

构建DateTime对象为SQL数据库插入

问题描述:

我的工作,需要用户输入(除其他事项外),他们增加了系统中的任何服务器的预定的备份时间一个小型Web窗体上。问题是,我挣扎找出拿用户的输入,并建立一个DateTime对象(这是数据库需要)的最佳方式。

I'm working on a small web form that requires the user to input (among other things), the scheduled backup time of whatever server they're adding to the system. The problem is, I'm struggling to find out the best way to take the user input and build a DateTime object (which is what the database requires).

我只真正关心周的日,日(12或24小时制)。时间

I only really care about the Day of Week, Time of Day (12 or 24 hour clock).

我想到了刚刚创建一个空的DateTime对象,然后从用户只需添加我的输入值,但你只能得到,不设置,一周中的一天,一天中的时间等。

I thought about just creating an empty DateTime object and then just adding my input values from the user, but you can only get, not set, the day of week, time of day, etc.

我一直在看日历ASP的控制,这一周选择当天的工作,但我似乎无法找到的一天任何时间的支持。

I've been looking at the Calender asp control, which would work for the day of the week selection, but I can't seem to find any support of time of day.

感谢。

我不认为你想用一个重复事件日期时间,如备份。一个DateTime是用于存储特定的日期和时间,而不是一个模板的一个经常性的事件是有用的。相反,我会用单独的列来存储星期值(0-6),时间和日期的当日(午夜后分钟)的事件。

I don't think you want to use a DateTime for a recurring event such as a backup. A DateTime is useful for storing a particular date and time, but not a "template" for a recurring event. Instead I'd use separate columns to store the day of week value (0-6) and time of date (minutes after midnight) for the event.