How to convert a double value to a DateTime in c#?

后端 未结 5 1423
-上瘾入骨i
-上瘾入骨i 2021-01-01 23:33

I have the value 40880.051388 and am storing it as a double, if I open Excel and paste in a cell and apply the following custom format \"m/d/yyyy h:mm\" to that

5条回答
  •  北海茫月
    2021-01-01 23:56

    The value is an offset in days from December 30th, 1899. So you want:

    new DateTime(1899, 12, 30).AddDays(40880.051388)
    

提交回复
热议问题