In case of Oracle the Query
select SYSDATE - TO_DATE('23-03-1022','dd-mm-yyyy') from dual;
is Giving the Output
SYSDATE-TO_DATE('23-03-1022','DD-MM-YYYY')
------------------------------------------
21715.2233
In case of EDB/Postgres it is-
select SYSDATE - TO_DATE('23-03-1022','dd-mm-yyyy') as date;
date
---------------------
21715 days 05:23:13
(1 row)
How can i get the Same output as oracle in case Of Postgres ?
What does .2233 tells in case of Oracle?
In Oracle,
SYSDATEis a function that returns both date and time component. Difference of twoDATEdatatype values returns number of days between them. Therefore, asSYSDATEalso contains hours, minutes and seconds, you'll almost always get a decimal number as the result (unless you run that piece of code at midnight).Therefore, I presume that you'd - actually - want to truncate
SYSDATEwhich then "removes" time component (sets it to 00:00:00):As of 0.2279: it is - as I said - number of days. To quickly demonstrate it: if you want to get number of hours, you'd multiply it by 24 (the rest by 60 to get minutes, and its rest by 60 again to get seconds):
Which means that you ran that query today at 05:28:10.