sql server - storing time and day of week -
challenge : have requirement in have implement recurring events. storing day of week , time , date range event reoccur.
possible solution: storing time , day of week string , enumeration. storing current , setting time , day day ?
question : best practice on storing time , day of week ?
edt: using sql server database
this best approach might dependson database using. but, there 2 general approaches, both quite reasonable.
the first store dates , times in native format database. databases have functions extract day of week , time date time type. write queries using these functions. typically, store these 1 field, might want separate date , time portions.
the second have calendar table. calendar table have date or dateid key, , contain columns want know it. day of week obvious column.
a calendar table preferred solution in situations. instance, if going internationalize application, being able day of week table makes easier string english, greek, chinese, russian, swahili, or whatever favorite language is. or, if want keep track of specific holidays, calendar table can store information well. or, if have business running on strange financial calendar (such 5-4-4), calendar table choice.
in either case, not need store redundant date information in table. should derive it, either built-in function or looking want in reference table.
Comments
Post a Comment