Convert DateTime to long and also the other way around

I want to store dates as numbers in a table. I know how to do that but I don't know how to go back. How can I cast a long variable to ToDateTime.

DateTime now = DateTime.Now;
long t = now.ToFileTime();
DateTime today = t.ToDateTime;  // I am looking for something like this line. This Method does not exist

I know there are many ways of converting DateTime to long. I don't mind which technique to use. I just want to have a way where I can convert back and forth.


Solution 1:

To long from DateTime:

long DateTime.Ticks

To DateTime from long:

new DateTime(long)

Solution 2:

use the pair long t = now.Ticks and DateTime Today = new DateTime(t)