All Forums Database
Kks 128 posts Joined 03/06
13 Aug 2008
How to convert minutes to H:M:S format

Hi all,is there any inbuilt function to convert minutes to H:M:S format in SQL Thanks

Adeel Chaudhry 773 posts Joined 04/08
13 Aug 2008

Hello,Can you please provide an example what exactly you want to do?Regards,Adeel

-- If you are stuck at something .... consider it an opportunity to think anew.

Kks 128 posts Joined 03/06
14 Aug 2008

Hi,What I am trying to achieve is like 312 minutes if converted will be like 05:12:00 (HMS) format

Jim Chapman 449 posts Joined 09/04
14 Aug 2008

select cast(interval '312' minute AS interval hour to minute); *** Query completed. One row found. One column returned. *** Total elapsed time was 1 second. 312------ 5:12

Kks 128 posts Joined 03/06
15 Aug 2008

Thanks for reply , This interval '312' canbe a column from table e.g. select cast(interval A minute AS interval hour to second);but I got syntax error .

Kks 128 posts Joined 03/06
15 Aug 2008

sorry e.g. is select cast(interval A minute AS interval hour to second) FROM TAB1;

Jim Chapman 449 posts Joined 09/04
15 Aug 2008

The form "INTERVAL 'string' MINUTE" is an interval literal. If you want to convert a character or integer type value, it seems that you need 2 casts. create table t1 (a int, b char(3)); *** Table has been created.insert into t1 values (312, '312'); *** Insert completed. One row added.select cast( cast(b as interval minute(3)) as interval hour to second(0) ) from t1; *** Query completed. One row found. One column returned. b--------- 5:12:00

22 Aug 2008

hello,I was trying to do this for seconds and i am running into issues.How can we convert a field that has integer (seconds) into time format hh:mm:ss?i was getting some interval field overflow errors, and Number of leading digits out of range. error.basically this is what we are trying to do.we want to create a table that has all the possible timesstarting from 00:00:00thru 23:59:59appreciate your help.

22 Aug 2008

got it!select '123' * CAST( INTERVAL '1' SECOND AS INTERVAL hour TO second(0));

You must sign in to leave a comment.