Convert seconds to datetime in SQL Server

后端 未结 3 447
悲&欢浪女
悲&欢浪女 2021-01-18 11:32

How to convert seconds to datetime? I try this, but results are not correct:

CONVERT(datetime, DATEADD(ms, dateTimeInSeconds, 0))
3条回答
  •  梦毁少年i
    2021-01-18 11:43

    Informative time span string:

    declare @seconds int = 93825
    
    convert(varchar,(@seconds/86400)) + 'd:' + format(dateadd(ss,@seconds,0),'HH\h:mm\m:ss\s')
    

    Result: 1d:02h:03m:45s

提交回复
热议问题