Coverting Minutes to TIME format ( HH:MI:SS:nnnnnn)

Bandi
Posted by Bandi under Sql Server category on | Points: 40 | Views : 330
The Convertion of Minutes to TIME is not possible directly..

DECLARE @Minutes INT = 606
SELECT CAST( @Minutes AS TIME) [TimeInHH:Mi:SS.nnnnnn]


Gives the below error,
Msg 529, Level 16, State 2, Line 3
Explicit conversion from data type int to time is not allowed.


Solution:


DECLARE @Minutes INT = 606
SELECT CAST( DATEADD( Mi, @Minutes, '1900-01-01') AS TIME)



TimeInHH:Mi:SS.nnnnnn
----------------------
10:06:00.0000000

Comments or Responses

Login to post response