Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Want to make the output human readable

enter image description here

Hello, I am trying to run some queries but my output is not right. Could anyone please help me understand what I’m doing wrong?
I am trying to find the difference between these two DATETIME values as minutes.

SELECT TO_CHAR(booking_StartTime - booking_EndTime) AS Diff FROM Booking;

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Assuming that booking_StartTime and booking_EndTime are DATE fields – when doing arithmetic using DATE values in Oracle the result is a number of DAYS. Thus, to get minutes you have to multiply by the number of minutes in a day, i.e. by 24 * 60, or 1440. Also – you probably want to subtract the start time from the end time, in order to get a positive value as the result.

SELECT TO_CHAR((booking_EndTime - booking_StartTime) * 1440) AS Diff FROM Booking;

should get you what you want.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading