I want to find the time difference so i am trying to use DATEDIFF option. But the problem is i am having the time values in hhmm format(eg: 1715). So it showing out of range error. so i want to convert it to hh:mm format. How to convert hhmm to hh:mm format?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Have you tried something like
DECLARE @TimeVal VARCHAR(4)
SELECT @TimeVal = '1715'
select CONVERT(DATETIME,LEFT(@TimeVal,2) + ':' + RIGHT(@TimeVal,2),8)
Output
1900-01-01 17:15:00.000
标签:
sql-server-2005