Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Calculating # of days,hours,mins
select record_id, to_char(sysdate-record_insert_timestamp, 'DD "Days", HH24
"Hours",
SELECT ROUND(rec_timestamp-SYSDATE) || ' Days '
|| TO_CHAR(TO_DATE(ABS(((rec_timestamp-SYSDATE) - ROUND(rec_timestamp-SYSDATE))*86400), 'SSSSS'), 'HH24') || ' Hours '
|| TO_CHAR(TO_DATE(ABS(((rec_timestamp-SYSDATE) -
ROUND(rec_timestamp-SYSDATE))*86400), 'SSSSS'), 'MI') || ' Minutes '
|| TO_CHAR(TO_DATE(ABS(((rec_timestamp-SYSDATE) -
ROUND(rec_timestamp-SYSDATE))*86400), 'SSSSS'), 'SS') || ' Seconds '
FROM dual
e.g.
1 SELECT ROUND(SYSDATE+40/25-SYSDATE) || ' Days '
2 || TO_CHAR(TO_DATE(ABS(((SYSDATE+40/25-SYSDATE) -
ROUND(SYSDATE+40/25-SYSDATE))*86400), 'SSSSS'), 'HH24') || ' Hours '
3 || TO_CHAR(TO_DATE(ABS(((SYSDATE+40/25-SYSDATE) -
ROUND(SYSDATE+40/25-SYSDATE))*86400), 'SSSSS'), 'MI') || ' Minutes '
4 || TO_CHAR(TO_DATE(ABS(((SYSDATE+40/25-SYSDATE) -
ROUND(SYSDATE+40/25-SYSDATE))*86400), 'SSSSS'), 'SS') || ' Seconds '
5* FROM dual
SQL> /
ROUND(SYSDATE+40/25-SYSDATE)||'DAYS'||TO_CHAR(TO_DATE(ABS(((SYSDATE+40/25-SY
SDAT
![]() |
![]() |