Convert Minutes to HH:MM:SS format

  • Hi, I am a noob to SQL. I am trying to convert a numeric field(which contains minutes) to HH:MM:SS format. Where do I start?

  • Try this

    SELECT CONVERT(char,DATEADD(mi, mindatafld, '1/1/1970'),108)

    unless goes over 12 hours.

    Also you might need to do something like this

    SELECT CAST(mindatafld / 60 as varchar(5)) + ':' + CAST(mindatafld % 60 as varchar(5)) + ':00'

    of course you will need to fix the minute position if not 2 characters in length, I didn't go into that.

    Probably can come up with at least one other way, but it is late and I am fried.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply