Which date function is used to find the difference between two dates?

MONTHS_BETWEEN

Showing Answers 1 - 28 of 28 Answers

keerthy

  • Nov 14th, 2005
 

datediff(month,fromdate,todate) -- this function will return the  no. of month between from and to date.

  Was this answer useful?  Yes

Amit Verma

  • May 2nd, 2007
 

datediff(mm,datetime1,datetime2) is the date function used in Microsoft SQL Server and Sybase Adaptive Server where as in oracle months_between( date2, date1) is the date function to find the difference. Both the functions returns the difference between the dates specified by the datetime1 and datetime2 variables. This difference is calculated in the number of months.

  Was this answer useful?  Yes

Tushar

  • May 9th, 2007
 

you can say
select date1-date2 from dual;             -- Returns no of days in decimal date+time

select trunc(date1-date2) from dual;  -- Returns no of days

  Was this answer useful?  Yes

Thangadurai

  • Jul 25th, 2007
 

SQL> select trunc(to_date('01-SEP-2007')-to_date('22-JUN-2007')) as Diffdate from dual;

  DIFFDATE
----------
        71


Reds
Thangam.

vani

  • Aug 8th, 2007
 

Select to_date('09-aug-2007')-to_date(sysdate) from dual;
would give the number of days between the two dates..

In oracle i found
select trunc(to_date('09-aug-2007')-to_date(sysdate) ) from dual;
giving the same result as the first query.

  Was this answer useful?  Yes

prashantyavadruth

  • Oct 7th, 2007
 

In Oracle SQL Months_between(Date1,Date2);  is the correct answer.

  Was this answer useful?  Yes

This is the inbuilt funcion of Sql server that gives you the difference between two diffrent dates as days "dd", month "mm" and year "yyyy" also at the place of formate specifier
this is also usefull to find out age or experience of employee.


Select datediff(mm, '1-1-2008', '1-31-2011')

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions