Wednesday, July 20, 2011

How do i convert minutes into hr:mm format in SQL??

some one asked me this question some time back... and again today i came across this question. so i thought of weel documenting it.

How do i convert minutes (probably stored as float in a column in a SQL table....) into hr:mm format??

cast(cast([Time]/60 as int) as varchar) + ':' + CAST(CAST([Time]%60 as int) as varchar) as 'hr:mm'

FROM [dbo].[TableA]

No comments:

Post a Comment