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?
Asked
Active
Viewed 367 times
2 Answers
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
-
This will not work as expected if `ticks` is obtained from `SqlDateTime.DayTicks`. – Slippery Pete Oct 17 '12 at 20:39