将时间计算转换为HH中的时间:mm
我希望在SQL Server中创建一个计算,该计算将显示HH_MM
中的时间差,从time
列中显示。
例如,
5:45 PM - 3:30 PM = 2:15 (desired output)
我能得到的最接近的时间和几分钟之间的差异是:
CONVERT(TIME,cals_END_time - cals_START_time) = 02:15:00.0000000
如何将其“修剪”到2:15?
I am looking to create a calculation in SQL Server that will display the time difference in HH_MM
from a time
column.
For example, the difference in hours and minutes between
5:45 PM - 3:30 PM = 2:15 (desired output)
The closest I have been able to get is this:
CONVERT(TIME,cals_END_time - cals_START_time) = 02:15:00.0000000
How do I go about 'trimming' it down to 2:15?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果要添加/减法日期/数据时间,则需要使用相关函数进行以下操作:
返回:
If you want to add/subtract dates/datetimes you need to use the relevant functions to do so as follows:
Returns:
假设列是
datetime
,请使用格式
函数到格式时间值:db<> fiddle
Assuming the columns are
datetime
, use theformat
function to format the time value:DB<>Fiddle