← Back

Post Thread

Oracle AI Database 23.26.1 added the DATEDIFF function:
DATEDIFF ( <unit>, <start date>, <end date> )

Despite the name this is not computing elapsed time. It counts the time boundaries crossed.

some examples:

#SQL> select DATEDIFF(year,sysdate-1000,sysdate) yr;
        YR
----------
         3
1 row selected.
#SQL>
#SQL> select DATEDIFF(month,sysdate-1000,sysdate) mth;
       MTH
----------
        33
1 row selected.
#SQL>
#SQL> select DATEDIFF(second,sysdate-1000,sysdate) secs;
      SECS
----------
  86400000
1 row selected.
#SQL>
#SQL> select DATEDIFF(microsecond,systimestamp-numtodsinterval(3.5,'SECOND'),systimestamp) us;
        US
----------
   3500000
0 Replies
0 Reposts