Saving Dates in SQLServer

后端 未结 7 1353
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-05 00:16

I have a legacy application where the input is a date string, i.e.:

06/12/2009

The format of the input is always a string, and i

7条回答
  •  灰色年华
    2021-01-05 00:21

    I'm a bit conservative in these matters, but I prefer to use separate Year / Month / Day fields in the table, rather than a Date field that uses a DBMS-specific data type. It certainly takes more space, but the lack of ambiguity and increased portability is worth it to me.

    The price you pay is that you don't get free date/time arithmetic and sorting, but it's easy enough to do yourself or by a slightly more complex "ORDER BY" clause.

提交回复
热议问题