Question

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?

Was it helpful?

Solution

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;

OTHER TIPS

Try this:

DateTime result = new DateTime(ticks);

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top