Convert .NET Ticks to SQL Server DateTime

后端 未结 7 896
攒了一身酷
攒了一身酷 2020-11-30 10:10

I am saving a TimeSpan (from .NET) value in my db as BIGINT in SQL Server (saving the Ticks property). I want to know how to convert this BIG

7条回答
  •  暖寄归人
    2020-11-30 10:41

    You should be able to use the CAST function built into SQL Server.

    SELECT(CAST(CAST(CAST ('02/02/10' AS datetime) AS BIGINT) AS datetime)) 
    

    you get 2010-02-02 00:00:00.000

提交回复
热议问题