That function doesn't exist in Oracle RDMBS; it clearly did in Oracle Lite (which I've never encountered) and I believe it's in other databases like MySQL.
There is documentation covering datetime and interval arithmetic which will get you part of the way there; you can either subtract one timestamp from another; or one date from another, or a mix of the two - but it's simpler to stick to one data type. Depending which you use you'll either get an interval or a number representing the number of days:
SQL> SELECT CURRENT_TIMESTAMP - TIMESTAMP '1998-12-09 00:00:00' FROM DUAL;
CURRENT_TIMESTAMP-TIMESTAMP'1998-12-0900:00:00'
---------------------------------------------------------------------------
+000006169 16:16:21.287166000
SQL> SELECT CURRENT_DATE - DATE '1998-12-09' FROM DUAL;
CURRENT_DATE-DATE'1998-12-09'
-----------------------------
6169.67775
If you just want the number of whole days you can use extract()
for the interval to get just the element you want, or trunc()
for the number to remove the fractional part:
SQL> SELECT EXTRACT(DAY FROM CURRENT_TIMESTAMP - TIMESTAMP '1998-12-09 00:00:00') FROM DUAL;
EXTRACT(DAYFROMCURRENT_TIMESTAMP-TIMESTAMP'1998-12-0900:00:00')
---------------------------------------------------------------
6169
SQL> SELECT TRUNC(CURRENT_DATE - DATE '1998-12-09') FROM DUAL;
TRUNC(CURRENT_DATE-DATE'1998-12-09')
------------------------------------
6169
You could also trunc()
the current date before comparison if you prefer, so you're comparing both at midnight, which means there won't be a fractional day part to remove:
SQL> SELECT TRUNC(CURRENT_DATE) - DATE '1998-12-09' FROM DUAL;
TRUNC(CURRENT_DATE)-DATE'1998-12-09'
------------------------------------
6169
I've used ANSI date literals for the fixed date, but you can use an existing date or timestamp variable or column; or to_date()
or to_timestamp()
if you have a string in a different format.
You can also use extract()
to convert an interval's components to a combined value, as shown here; and also make sure you're aware of the difference between current_date
and sysdate
, and the timestamp equivalents.