我有以下查询。
select cast(dateadd(minute, datediff(minute, TimeIn, TimeOut), 0) as time(0) )
我以小时-分钟-秒的格式从两列中得到结果。
我只想要 min 的格式。所以
02:47:00
会读167
.
最佳答案
SQL Server 查询:
SELECT cast(substring('02:47:00',1,2) AS int)*60+
cast(substring('02:47:00',4,2) AS int)+
cast(substring('02:47:00',7,2) AS int)/60.0 AS minutes
MYSQL 查询:
SELECT TIME_TO_SEC('02:47:00') / 60
结果:
| MINUTES |
-----------
| 167 |
关于tsql - 转换 HH :MM:SS string to number of minutes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14746849/