Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dates conversion

Status
Not open for further replies.

Kido

Programmer
Dec 10, 2001
29
KE
If I want to get the number of days between two dates say 01/01/1995 and 26/12/2000, it is simply
(26/12/2000)- (01/01/1995). Now the problem is converting the days into years. Any idea?
 
That could work but its not accurate as it is assuming 31 days in a month.
 
The official number of days in a year is 365.2525.
 
Kido, why do you think so? It makes no "hardcoded" assumptions about month length:

Code:
SQL> select months_between(to_date('01.03.05','dd.mm.rr')
  2  ,to_date('01.02.05','dd.mm.rr')) month,
  3  to_date('01.03.05','dd.mm.rr')
  4  -to_date('01.02.05','dd.mm.rr') days
  5  from dual;

     MONTH       DAYS
---------- ----------
         1         28

Regards, Dima
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top