Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Requested - turning seconds into minutes and seconds

Status
Not open for further replies.

AmyJane

MIS
Nov 4, 2000
1
AU
URGENT:
I am doing an Oracle assignment using SQL and PLSQL. The basic topic of the assignment is this guy who wants to store all his cd's/tapes etc in a database. I need to store the length of each song on an album and be able to calculate the total length of the album.
I have therefore stored song lengths as seconds, e.g a song which is 7 minutes, 23 seconds long has been stored as 443 seconds. However, how can I use sql in Oracle to be able to transform this back to minutes and seconds (as number of seconds would not be that useful to the user, they'd want to know how long the cd is in minutes and seconds). PLEASE HELP ME IF YOU CAN.
 
The number of minutes and seconds in 447 seconds is

select trunc(447/60), mod(447,60) from dual
 
Try this
SELECT TO_CHAR ( TO_DATE ( <seconds> , 'SSSSS' ) , 'MI:SS' ) FROM ...

For example
SELECT TO_CHAR ( TO_DATE ( 443 , 'SSSSS' ) , 'MI:SS' ) FROM DUAL;

TO_CH
-----
07:23
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top