Home > Enterprise >  How to convert an integer value to time (HH:MM:SS) in SQL Server?
How to convert an integer value to time (HH:MM:SS) in SQL Server?

Time:09-12

I have a set of integer value which can be either a single digit to 6 digit number. Now I want to convert this set of values to time representing the HH:MM:SS format. I thought of converting first to varchar then to time but it didn't work out. Can anyone help me out with the problem?

CodePudding user response:

You can use TIMEFROMPARTS

SELECT
  TIMEFROMPARTS(
    YourColumn / 10000,
    YourColumn / 100 % 100,
    YourColumn % 100
  )
FROM YourTable;

CodePudding user response:

Try - date (dateadd(second,value,'19700101'))

  • Related