Hi !
There is no such built-in function for this. You will have to do it urself.
Riaz
Main Topics
Browse All TopicsIs there a built in oracle function that will give the number of days since a certain (built in oracle) date? eg given 01/01/2000 it would return a number representing the number of days since 01/01/1900 the given date is.
I know that i can do it myself using
select (given date) - (a chosen base date)
from sys.dual;
But if there is a function it would be quicker than doing a repeated number of queries as i have a large data set.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Since there is a bug (since version 6 allready) in the julian date arithmetic in oracle, merely subtracting dates is not allways a good solution.
select to_date('01010001AD','DDMM
At first glance this would be correct, however the year 0 does not exist, therefore the correct answer should be 1.
Also since the (non-existing)year 0 is a millennium year, it should not be 366 days but 265 days, as leap years do not exist on millenium dates.
Following function can be used to calculate the days between to dates:
create or replace function days_between wrapped
a000000
b2
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
8
170 12c
N+bvQHKyBlSljERVNnueObHaGj
CFELis2xMqzLn5PhqL06nRRCPm
8bDD4ZhXPgBl7qam2Tgru2eU30
mbEP72lJJ68sMwbxanTQyFIdxl
4fORcMA=
/
execute as SYS, grant to public and the function days_between returns the correct dates.
Business Accounts
Answer for Membership
by: zsoltvinczePosted on 2002-10-30 at 04:17:54ID: 7387185
There is only a months_between function. You can however create a function and use it for this purpose.
TE-5) -----
create function days_between (d1 date , d2 date) return number is
begin
return d1 - d2;
end;
now you can use the function as
select days_between(sysdate, sysdate - 5) from dual;
***********
SQL> create function days_between (d1 date , d2 date) return number is
2
3 begin
4 return d1 - d2;
5 end;
6 /
Function created.
SQL> select days_between(sysdate, sysdate - 5) from dual;
DAYS_BETWEEN(SYSDATE,SYSDA
--------------------------
5
SQL>
SQL>