No milliseconds value when reading DateTime values from a SQL database in C#

后端 未结 5 1844
我在风中等你
我在风中等你 2021-01-02 02:04

I have high precision dates stored in an SQL server, e.g.

2009-09-15 19:43:43.910

However when I convert that value into a DateTime the mil

5条回答
  •  無奈伤痛
    2021-01-02 02:18

    I had the same problem, and I solved it by persisting the C# DateTime as a SQL bigint populated with DateTime.Ticks. This preserves the full DateTime precision. And of course can be de-serialized with the DateTime(long ticks) constructor.

提交回复
热议问题