locked
Oracle to SQL migration :: Function to find the months difference of the two dates in SQL which is similar to MONTHS_BETWEEN function in Oracle RRS feed

  • Question

  • We are running a Migration project from Oracle9i to Sqlserver2008 and halted with a problem as below::

    In oracle MONTHS_BETWEEN function is giving the months difference in decimals.

    EX :: SELECT months_between(to_Date('2010/11/30','YYYY/MM/DD'),to_date('2009/12/01','YYYY/MM/DD')) from dual

    it is giving the value 11.9354838709677

    where as when i am using the datediff in SQL as

    SELECT

     

    DATEDIFF(mm,'2009/12/01','2010/11/30'),  it is giving me the value 11

    Reuqest you to suggest me the equivalent function in SQL.

    We tried the following things ::

    SELECT

     

    (DATEDIFF(dd,'2009/12/01','2010/11/30')/(364.25/12.0)),   but still it is not coming anywhere nere to this value.

    Monday, December 13, 2010 3:53 PM