Reputation: 59
I have a SQL server job that goes out and imports a text file. one line of this job is as follows:
SUBSTRING(Line, 61, 5) AS Col06,
This is getting a 5 digit number (the duration of a call) and placing it into a nvarchar(50) field. I would like to convert this into HH:MM:SS
.
Can you assist? I am quite new to this so explain as if I was stupid.
Upvotes: 1
Views: 378
Reputation: 148524
YOu can try this:-
where 1000 is the number of seconds
SELECT CONVERT(CHAR(8),DATEADD(second,1000,0),108)
Example :
SELECT CONVERT(CHAR(8),DATEADD(second,CAST (SUBSTRING('the call was 10000 seconds', 14, 5) AS INT),0),108)
Upvotes: 1