Say you have a table holds_date with an end_date and start_date columns of date data types.
If you say
SELECT (END_DATE-START_DATE)*24 FROM HOLD_DATES
you will get the desired outcome.
Please note if a date field is populated with just the date component of date time, then the default for the time is midnight.
So, please ensure the data is correct, you can view the date component of a date field by formatting the output. This will ensure that when you are subtracting date/time your time components are correct.
SELECT TO_CHAR(END_DATE, 'MM/DD/YYYY HH24:MI') FROM HOLD_DATES
Dig Deeper on Using Oracle PL-SQL
Related Q&A from Azim Fahmi
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.