問題描述
我正在為處理調度和處理重復事件的應用程序創建一個表.我需要指出事件可能在哪些日期和時間再次發生(例如,每周一和周三下午 1 點).是否有一種數據類型可以在不輸入特定日期的情況下只處理一周中的幾天,或者我是否需要創建另一個包含一周中的幾天的表并用 FK 引用這些?這顯然是不可取的,因為它會使處理在午夜之前開始并在午夜之后結束的事件變得更加復雜.
I am creating a table for an application that handles scheduling and deals with recurring events. I need to indicate which days and times an event may recur on (eg. every Monday and Wednesday at 1pm). Is there a datatype that can handle only days of the week without inputting specific dates, or will I need to create another table containing days of the week and reference these with a FK? This is obviously undesirable because it will make handling events that start before midnight and end after midnight more complex.
推薦答案
在星期幾使用 smallint.
Use a smallint for the Day of Week.
如果您使用的是 SQL Server 2008,則有一個新的time 時間列的數據類型,否則您仍然需要使用日期時間數據類型.
If you are using SQL Server 2008, there is a new time datatype for the time of day column, otherwise you will still need to use a datetime datatype.
這篇關于SQL Server 日數據類型?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!