1

I have a date value stored as an integer in a database that was created using the SQLDateTime DayTicks function. How can I reverse engineer that integer value back into a DateTime value?

Mathias
  • 15,191
  • 9
  • 60
  • 92
John44
  • 21
  • 2

2 Answers2

1

You will lose the time portion of the date unless you also have timeTicks floating around somewhere. This will convert the dayTicks back into a DateTime:

SqlDateTime sdt = new SqlDateTime(dayTicks, 0);
DateTime dt = sdt.Value;
Slippery Pete
  • 3,051
  • 1
  • 13
  • 15
0

Try this:

DateTime result = new DateTime(ticks);

There is an overload of the DateTime constructor that takes the number of ticks.

Dave Zych
  • 21,581
  • 7
  • 51
  • 66