Convert .NET Ticks to SQL Server DateTime

I don’t really know SQL Server, but today a colleague of mine had the same problem and I think I’ve found a solution like this:

CAST(([ticks] - 599266080000000000) / 10000000 / 24 / 60 / 60 AS datetime)

where 599266080000000000 is the ticks value for 01/01/1900 00:00:00.

Leave a Comment