To convert a DateTime
to a TimeSpan
you should choose a base date/time - e.g. midnight of January 1st, 2000, and subtract it from your DateTime
value (and add it when you want to convert back to DateTime
).
If you simply want to convert a DateTime
to a number you can use the Ticks property.