I want to subtract 2 dates and represent the result in hour and minute in one decimal figure.
I have the following table and I am doing it in this way but the result
Edit: if you need a number, then
trunc(end_date-start_date)*24+
to_number(to_char(trunc(sysdate)+(end_date-start_date),'HH24.MI'))
For string result, if delta is LESS THAN 24H: I would go with
to_char(trunc(sysdate)+(end_date-start_date),'HH24.MI')
or ...'HH24:MI:SS', but thats my personal preference.
for longer than 24H terms, I would prefix with
trunc(end_date-start_date)||"days "||
to_char(trunc(sysdate)+(end_date-start_date),'HH24.MI')
Yes, as oracle counts in days, with seconds precision, you are dealing with arithmetical problems. Once because you are only handling minutes (so you might round your number to trunc(days*24*60+0.5)/24/60), but the binary arithmetic imprecision on the number 1/24/60 might still cause you troubles.
Edit2.1:
to_char(24*(trunc(end_date)-trunc(start_date))+to_number(to_char(end_date,'HH24.MI'))-to_number(to_char(start_date,'HH24.MI')),'99999.99')
But The result could be quite confusing for the average, as the decimal 7.50 would suggest seven and a half hour, or at least 7 hour 50 minutes, opposed to the elapsed time of 7 hours 10 minutes.