|
|
|
Supreme 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
|
|
|
|
|
Supreme 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
|
|
|
|
|
Supreme 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
|
|
|
|
|
Supreme 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
|
|
|
|
|
Supreme 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 .
|
|
|
|
|
Supreme 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;
|
|
|
|
|
Supreme 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
|
|
|
|
|
Supreme 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
|
|
|
|
| | |