Efficient way to convert second to minute and seconds in sql server 2005

后端 未结 3 799
無奈伤痛
無奈伤痛 2020-12-10 02:14

Suppose I have 90 seconds. If I want to display the result in terms of minutes and second, I do it by using

select Time= \'0\' + CAST( 90/60 as varchar(2)) +         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-10 03:05

    With hours:

    SELECT CONVERT(CHAR(8),DATEADD(second,90,0),108)
    00:01:30
    

    Ignoring hours:

    SELECT RIGHT(CONVERT(CHAR(8),DATEADD(second,90,0),108),5)
    01:30
    

提交回复
热议问题