I have a date field containing date and time.
How do I calculate the difference in minutes between this date and sysdate?
Thanks
Printable View
I have a date field containing date and time.
How do I calculate the difference in minutes between this date and sysdate?
Thanks
The long way.Code:select inst.thedate,
instr(inst.thedate,':') FirstOne,
instr(inst.thedate,':',instr(inst.thedate,':')+1) SecondOne,
substr(Inst.thedate,instr(inst.thedate,':')-2,2) TheHours,
substr(Inst.thedate,instr(inst.thedate,':')+1,2) TheMins,
substr(Inst.thedate,instr(inst.thedate,':',instr(inst.thedate,':')+1)+1,2) TheSecs,
to_number(substr(Inst.thedate,instr(inst.thedate,':')-2,2))*60 + to_number(substr(Inst.thedate,instr(inst.thedate,':')+1,2)) TheTotalMins
From
(select to_char(localtimestamp-to_timestamp('28-jul-05 12.20.53.466428')) thedate
from tablename
where tablename.id=1048) Inst
I expect there is a function somewhere in Oracle that does it, but I couldn't see it straight off.
Edit:
Also found an Extract function - although I couldn't get it to work.