問題描述
我正在為處理調(diào)度和處理重復事件的應用程序創(chuàng)建一個表.我需要指出事件可能在哪些日期和時間再次發(fā)生(例如,每周一和周三下午 1 點).是否有一種數(shù)據(jù)類型可以在不輸入特定日期的情況下只處理一周中的幾天,或者我是否需要創(chuàng)建另一個包含一周中的幾天的表并用 FK 引用這些?這顯然是不可取的,因為它會使處理在午夜之前開始并在午夜之后結(jié)束的事件變得更加復雜.
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 時間列的數(shù)據(jù)類型,否則您仍然需要使用日期時間數(shù)據(jù)類型.
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.
這篇關(guān)于SQL Server 日數(shù)據(jù)類型?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!