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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date format

Status
Not open for further replies.

wsam

MIS
Apr 27, 2001
19
CA
I am subtracting two dates date1 - date2 I have found that to_char((date1 - date2)*1440) give me the minutes between the two dates,but I would like to get the format of hh:mi:ss for the results. Can anyone help.

Thanks in advance.

 
When you subtracted the 2 dates and multipled by 1440, you created an integer. The date format is gone and you cannot directly get HH:MI:SS using to_char.

Are you trying to figure out how many hours, minutes and seconds are between the 2 dates? If so...let's use 44645 as the number of seconds calculated..

For hours, divide the result by 3600 and trunacte the result for hours: floor(44645/3600) = 12 hours

For minutes, take the even remainder (mod) of the number of hours: floor(mod(44645,3600)/60) = 24 minutes

For seconds, take the even remainder (mod) of the number of minutes: mod(mod(44645,3600),60) = 5 seconds

I hope this is what you needed.
=================================
Thomas V. Flaherty Jr.
Birch Hill Technology Group, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top