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.
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.