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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date1 - date2 = day

Status
Not open for further replies.

specv

Programmer
Aug 8, 2001
42
CA
Hi,

In Oracle database select, I want to find the number of days separate two dates.

ex : July 20, 2001 - July 15, 2001 = 5 days

Is it possible?

Thanks

Phil
 
Yes, you should be able to subtract dates and get a difference in days. The query would be something like

select to_date('20-JUL-01') - to_date('15-JUL_01') from dual;
 

ANSI SQL uses To_Days
SELECT TO_DAYS('2001-7-12') - TO_DAYS('2000-11-25')


SQL Server uses Datediff
Select datediff(day,'2001-7-12','2000-11-25')
Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top