问题
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
来源:https://stackoverflow.com/questions/4130485/time-format-hhmm-to-hhmm-sql-server-2005