22 Replies Latest reply: Mar 19, 2018 10:07 PM by Tony THOMPSON RSS

    How Do I Get the Number of Months Between Two Dates?

      Other posts here in the forii have mentioned Interval() to get the number of days or months between two days.  However, I have not found a format code to get months.  Either of these expressions...

       

      =Interval#(Today() - [Set up date], 'YY-MM-DD')

      =Interval#(Today() - [Set up date], 'YY-MM')

       

      ...give me the number of days since [Set up date], but I need months.  Using 'MM' gives the value "2614" for all dates from 2005 to yesterday - I have no idea where that number comes from.  The doc page for Interval() is of course useless.

       

      If there's a simpler way to get the number of months between two dates, such as is present in any RDMS (e.g., DATEDIFF() in MSSQL and MySQL, MONTHS_BETWEEN() in Oracle), I am all ears.  If someone suggests adding the difference in years times 12 to the difference in months, I fear I may lose any remaining faith in QlikView.

       

      Thank you!