tags:

views:

81

answers:

4

is there easy way to store dates as number and convert number to date equivalent in .NET 3.5 such as julian date format?.

+4  A: 

You can use DateTime.Ticks to convert a DateTime to a number (more specifically - a long). Use the constructor that takes ticks to convert back.

Mark Byers
+1  A: 

This should work fine for you

      DateTime date = DateTime.Now;
      long dateAsLong = date.ToFileTime();
      DateTime orgDate = DateTime.FromFileTime(dateAsLong);
Dennis
+3  A: 
DateTime.ToOADate() → double → DateTime.FromOADate()
DateTime.ToFileTime() → long → DateTime.FromFileTime()
DateTime.ToFileTimeUtc() → long → DateTime.FromFileTimeUtc()

All of these methods will convert a DateTime to a numeric.

Paul Ruane
A: 

Time Tick gives a big number with lot of zeros so its not suitable for asp.net query string parameter values but might work for some other situations.So julian date conversions are the most easy and nice way to use in asp.net query string date value passing between pages

DSharper