我的duration
表格中有一个time(7)
列appointments
列。
我知道如何使用
获得预约的分钟数select durationMinutes = DateDiff(n, a.StartOn, a.EndOn)
from appointments a
但我的duration
列是time(7)
。
如何将int
转换为duration
?
答案 0 :(得分:1)
您可以尝试使用DATEADD功能并将分钟添加到00:00:00时间。
DATEADD(MINUTE, @durationMinutes, '00:00:00')
答案 1 :(得分:0)
declare @Time as Time(7) = '01:02:03';
select @Time as 'Time(7)', DateDiff( minute, 0, @Time ) as 'Minutes';
declare @Minutes as Int = 90;
select @Minutes as 'Minutes', Cast( DateAdd( minute, @Minutes, 0 ) as Time(7) ) as 'Time(7)';