如果我有两个这样的日期时间:
transtime_in, transtime_out
如何以以下格式获取这些日期时间之间的差异:
hh:mm
<小时/>
我用
DATEDIFF(hour, transtime_in, transtime_out)
但我只得到时间。
最佳答案
试试这个 -
查询:
DECLARE
@transtime_in DATETIME
, @transtime_out DATETIME
SELECT
@transtime_in = '2013-05-19 08:58:07.000'
, @transtime_out = '2013-05-19 16:40:53.000'
SELECT LEFT(CONVERT(VARCHAR(10), @transtime_out - @transtime_in, 108), 5)
输出:
-----
07:42
关于sql - 如何获取两个日期时间之间的小时和分钟差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16645641/