Reputation: 581
How can convert a datetime to double?
Upvotes: 7
Views: 11919
Reputation: 10213
A better approach than ToOADate
is to use this:
double timestamp = DateTime.UtcNow.Ticks;
See this post where precision is lost when doing DateTime.Now.AddTicks(1000).ToOADate()
, if the example there were changed to (double)DateTime.Now.AddTicks(1000).Ticks
the precision is not lost.
Upvotes: 1