Should I store DateTimes as a Long (Ticks) in a database?

后端 未结 4 2075
刺人心
刺人心 2021-01-12 11:00

Could life be made easier by saving DateTime values as a long instead? There always seem to be problems when working with null DateTime values, whether storing

4条回答
  •  情书的邮戳
    2021-01-12 11:52

    In some cases, yes. Sql stores datetimes at a lower precision than DateTime. This means that a value persisted and retrieved may have a slightly different DateTime value from the original object, which might cause some issues with ordering or comparison.

提交回复
热议问题