Take the time from the datetime and convert it into seconds?

后端 未结 3 1722
故里飘歌
故里飘歌 2021-02-13 18:52

I am running SQL Server 2005. Technically I know how to take the time from a tsql datetime.

CONVERT(VARCHAR(8),GETDATE(),108) AS HourMinuteSecond
3条回答
  •  故里飘歌
    2021-02-13 19:03

    Use DATEPART:

    (DATEPART(HOUR, GETDATE()) * 3600) +
    (DATEPART(MINUTE, GETDATE()) * 60) +
    (DATEPART(SECOND, GETDATE()))
    

提交回复
热议问题