Tim J
Tim J

Reputation: 11

How to convert time integer format to datetime in SQL Server

I have a timestamp column in SSMS with the time expressed as an integer like this:

8:02:48 written as 80248

Is there a way I can use code to convert this timestamp integer to a date format (ie. HH:MM:SS)? I've been googling around for a while but have been unable to find something that works.

Upvotes: 0

Views: 378

Answers (1)

user1443098
user1443098

Reputation: 7675

This worked with your data:

SELECT TIMEFROMPARTS(80248/10000, (80248 - 80248/10000*10000)/100, (80248 - 80248/10000*10000) - (80248 - 80248/10000*10000)/100*100, 0, 0)

Upvotes: 1

Related Questions