How to convert minutes to H:M:S format
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


How to convert minutes to H:M:S format Expand / Collapse
Author
Message
Posted 8/13/2008 7:03:12 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Yesterday @ 12:19:18 PM
Posts: 119, Visits: 68
Hi all,

is there any inbuilt function to convert minutes to H:M:S format in SQL

Thanks
Post #12574
Posted 8/13/2008 7:09:56 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Yesterday @ 7:30:07 AM
Posts: 197, Visits: 611
Hello,

Can you please provide an example what exactly you want to do?

Regards,

Adeel
Post #12575
Posted 8/14/2008 4:39:53 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Yesterday @ 12:19:18 PM
Posts: 119, Visits: 68
Hi,
What I am trying to achieve is like 312 minutes
if converted will be like 05:12:00 (HMS) format
Post #12591
Posted 8/14/2008 2:01:14 PM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 12/1/2008 3:54:26 PM
Posts: 225, Visits: 541
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
Post #12600
Posted 8/15/2008 3:52:17 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Yesterday @ 12:19:18 PM
Posts: 119, Visits: 68
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 .
Post #12606
Posted 8/15/2008 3:53:13 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Yesterday @ 12:19:18 PM
Posts: 119, Visits: 68
sorry e.g. is

select cast(interval A minute AS interval hour to second) FROM TAB1;


Post #12607
Posted 8/15/2008 1:59:42 PM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 12/1/2008 3:54:26 PM
Posts: 225, Visits: 541
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
Post #12614
Posted 8/22/2008 11:46:02 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 10/7/2008 12:54:51 PM
Posts: 116, Visits: 20
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 times
starting from 00:00:00
thru 23:59:59

appreciate your help.


Feroz Shaik
Post #12701