Tejaswi Yerukalapudi Tejaswi Yerukalapudi - 10 months ago 71
C# Question

DateTime's representation in milliseconds?

I have a SQL-server timestamp that I need to convert into a representation of time in milliseconds since 1970. Can I do this with plain SQL? If not, I've extracted it into a

variable in C#. Is it possible to get a millisec representation of this ?



Answer Source

You're probably trying to convert to a UNIX-like timestamp, which are in UTC:

    new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)

This also avoids summertime issues, since UTC doesn't have those.