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

后端 未结 3 1707
故里飘歌
故里飘歌 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:15

    The functions you want is DatePart

    Declare @d DateTime
    Select @d = GetDate()
    Select (DatePart(HOUR, @d) * 3600) + (DatePart(MINUTE, @d) * 60) + DatePart(SECOND, @d)
    

提交回复
热议问题