Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server day datatype?

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.

like image 902
Andrew Keller Avatar asked Mar 14 '26 01:03

Andrew Keller


1 Answers

Use a smallint for the Day of Week.

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.

like image 115
Mitch Wheat Avatar answered Mar 16 '26 00:03

Mitch Wheat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!