var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Date calculation
In a table I have 2 dates storing a contract starting and ending date. I need the difference between the two in days or in months.
In SQL Server, there is a DATEDIFF function that does exactly that. I can't find something like that with Oracle 9i.
I need to do this in a SQL statement.
Thanks a lot.
Yes, There is date function "MONTHS_BETWEEN" Look at the following example.
SQL> select months_between(to_date('05-26-2004','MM-DD-YYYY'),
2 to_date('01-01-2004','MM-DD-YYYY')) "Months"
3 from dual;
I hope this will help.
But I of course tried "days_between" and it does not exist as a function. So. What is the magic combo of functions to calculate the number of days between 2 dates?
Oracle has built in date math, so
date1 - date2
returns the number of days between the 2 dates.
sysdate - trunc(sysdate)
gives the number of days since midnight, so at 6pm the answer is .75 (days).
I was just about to post that I figured it out. Thanks.