0

I try to get the difference between 20201001-20200930 is 71 not 1 day try to get difference between sysdate(20201127) and 20200106 is 1021 10 refer to number of months and 21 refer to the number of days

select GetDate(sysdate)-floor(D.INIT_TIMESTAMP) FROM T_NOTIFICATION

I try to get the difference between 20201001-20200930 is 71 not 1 day

  • 1
    Does this answer your question? [How can I get the number of days between 2 dates in Oracle 11g?](https://stackoverflow.com/questions/1646001/how-can-i-get-the-number-of-days-between-2-dates-in-oracle-11g) – Abra Nov 27 '20 at 12:34
  • 1
    What is the type of input data you have? There's no `getdate` function in Oracle. Moreover, I do not know any DBMS that can have some input parameter for `getdate` or its analog. – astentx Nov 27 '20 at 13:18

2 Answers2

0

Juste convert into DATE datatype before computing the difference.

SELECT TO_DATE('20201001', 'YYYYMMDD') - TO_DATE('20200930', 'YYYYMMDD') 
FROM dual;

EDIT : IYYY changed into YYYY according Oracle docs -> https://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements004.htm#i34924

Florent
  • 436
  • 3
  • 8
0

There is no GetDate function in Oracle. Try this one:

TRUNC(sysdate) - TO_DATE(20200106, 'YYYYMMDD')
TO_DATE(20201001, 'YYYYMMDD') - TO_DATE(20200930, 'YYYYMMDD')
Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110