Frage

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?

War es hilfreich?

Lösung

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;

Andere Tipps

Try this:

DateTime result = new DateTime(ticks);

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top