<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How Do I Get the Number of Months Between Two Dates? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296936#M495860</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The length of months differs, but the number of months between two dates is defined quite consistently across most or all RDMSs: the number of month boundaries crossed from A to B.&amp;nbsp; Any day in February to any day in March is one month; any day in March to any other day in March is zero months, etc.&amp;nbsp; Taking the number of days and dividing it by 30.5 would give inaccurate results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using 30.438333 as a divisor would be close over the long term, but would still report 03/01 to 03/31 as being a period of one month, against this business need and (IMHO) against most people's intuitive sense.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Feb 2012 15:44:40 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-02-20T15:44:40Z</dc:date>
    <item>
      <title>How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296928#M495852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Other posts here in the forii have mentioned Interval() to get the number of days or months between two days.&amp;nbsp; However, I have not found a format code to get months.&amp;nbsp; Either of these expressions...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=Interval#(Today() - [Set up date], 'YY-MM-DD')&lt;/P&gt;&lt;P&gt;=Interval#(Today() - [Set up date], 'YY-MM')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...give me the number of &lt;EM&gt;days&lt;/EM&gt; since [Set up date], but I need months.&amp;nbsp; Using 'MM' gives the value "2614" for all dates from 2005 to yesterday - I have no idea where that number comes from.&amp;nbsp; The doc page for Interval() is of course useless.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Feb 2012 00:01:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296928#M495852</guid>
      <dc:creator />
      <dc:date>2012-02-18T00:01:32Z</dc:date>
    </item>
    <item>
      <title>How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296929#M495853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should be able to do the same formula in qlikview.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://support.microsoft.com/kb/214134"&gt;http://support.microsoft.com/kb/214134&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Feb 2012 01:11:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296929#M495853</guid>
      <dc:creator>disqr_rm</dc:creator>
      <dc:date>2012-02-18T01:11:30Z</dc:date>
    </item>
    <item>
      <title>How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296930#M495854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; You could always create your own custom function in the module:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Function MonthDiff (startdate, enddate)&lt;/P&gt;&lt;P&gt;' return number of months between two dates&lt;/P&gt;&lt;P&gt; If IsDate(startdate) and IsDate(enddate) Then&lt;/P&gt;&lt;P&gt;&amp;nbsp; MonthDiff = DateDiff("m", startdate, enddate)&lt;/P&gt;&lt;P&gt; End If&lt;/P&gt;&lt;P&gt;End Function &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then just use it in the script eg&lt;/P&gt;&lt;P&gt;MonthDiff(text(W1DEL1), text(today()))) * 12))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I never did find an easier way myself!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gordon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Feb 2012 09:52:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296930#M495854</guid>
      <dc:creator />
      <dc:date>2012-02-18T09:52:57Z</dc:date>
    </item>
    <item>
      <title>How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296931#M495855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Jonathan,&lt;/P&gt;&lt;P&gt;Since "Month" is not a fixed length interval, you have to define a rule.&amp;nbsp; For practical purposes, this can be a reasonable approximation:&lt;/P&gt;&lt;P&gt;round((interval#(Today()-[Set up date], 'DD')/30.5), 0.1)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Feb 2012 15:33:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296931#M495855</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-02-18T15:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296932#M495856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry to shake your faith in QV &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;, but the expression I would use is:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;=((year(today(2))*12)+month(today(2))) - (((year([Set up date])*12)+month([Set up date])))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can ease your pain somewhat by creating a variable function in the script:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;SET MonthDiff=((year(today(2))*12)+month(today(2))) - (((year($1)*12)+month($1)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then in the chart:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;=$(MonthDiff([Set up date]))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 09:27:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296932#M495856</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2012-02-20T09:27:57Z</dc:date>
    </item>
    <item>
      <title>How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296933#M495857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ue below&amp;nbsp; code &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #636363; font-family: Arial; font-size: 12px; background-color: #eef4f9;"&gt;Interval(Today() - [Set up date], 'mm')&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 09:32:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296933#M495857</guid>
      <dc:creator>SunilChauhan</dc:creator>
      <dc:date>2012-02-20T09:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296934#M495858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The EDate() and LDate() functions, useful though they are in Excel, do not exist in QlikView.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 15:37:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296934#M495858</guid>
      <dc:creator />
      <dc:date>2012-02-20T15:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296935#M495859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm specifically looking for an expression in the QlikView document itself (e.g., a dimension in a pivot table), not the script.&amp;nbsp; There are over a dozen date metrics in the data set, so it would be impractical to calculate all possible date differences in the script.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 15:40:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296935#M495859</guid>
      <dc:creator />
      <dc:date>2012-02-20T15:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296936#M495860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The length of months differs, but the number of months between two dates is defined quite consistently across most or all RDMSs: the number of month boundaries crossed from A to B.&amp;nbsp; Any day in February to any day in March is one month; any day in March to any other day in March is zero months, etc.&amp;nbsp; Taking the number of days and dividing it by 30.5 would give inaccurate results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using 30.438333 as a divisor would be close over the long term, but would still report 03/01 to 03/31 as being a period of one month, against this business need and (IMHO) against most people's intuitive sense.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 15:44:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296936#M495860</guid>
      <dc:creator />
      <dc:date>2012-02-20T15:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296937#M495861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tried that.&amp;nbsp; As reported above, it gave a value which was much too high.&amp;nbsp; Expanding on the example, if I use this formula:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;='From ' &amp;amp; Text(Today())&lt;/P&gt;&lt;P&gt;&amp;amp; ' to '&lt;/P&gt;&lt;P&gt;&amp;amp; Text(Date#([Set up date]))&lt;/P&gt;&lt;P&gt;&amp;amp; ' is '&lt;/P&gt;&lt;P&gt;&amp;amp; Interval#(Today() - Date#([Set up date]), 'MM')&lt;/P&gt;&lt;P&gt;&amp;amp; ' months'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...I get values like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 324px;"&gt;&lt;TBODY&gt;&lt;TR style="height: 12.0pt;"&gt;&lt;TD height="16" style="height: 12.0pt; width: 243pt;" width="324"&gt;From 2012/02/20 to&amp;nbsp; 2006/03/10 is 2173 months&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 12.0pt;"&gt;&lt;TD height="16" style="height: 12.0pt;"&gt;From 2012/02/20 to 2006/11/13 is 1925&amp;nbsp; months&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 12.0pt;"&gt;&lt;TD height="16" style="height: 12.0pt;"&gt;From 2012/02/20 to 2006/11/14 is 1924&amp;nbsp; months&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 12.0pt;"&gt;&lt;TD height="16" style="height: 12.0pt;"&gt;From 2012/02/20 to 2006/04/04 is 2148&amp;nbsp; months&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 12.0pt;"&gt;&lt;TD height="16" style="height: 12.0pt;"&gt;From 2012/02/20 to 2008/02/17 is 1464&amp;nbsp; months&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 12.0pt;"&gt;&lt;TD height="16" style="height: 12.0pt;"&gt;From 2012/02/20 to 2007/12/04 is 1539&amp;nbsp; months&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 12.0pt;"&gt;&lt;TD height="16" style="height: 12.0pt;"&gt;From 2012/02/20 to 2007/09/04 is 1630&amp;nbsp; months&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 12.0pt;"&gt;&lt;TD height="16" style="height: 12.0pt;"&gt;From 2012/02/20 to 2007/12/14 is 1529&amp;nbsp; months&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 12.0pt;"&gt;&lt;TD height="16" style="height: 12.0pt;"&gt;From 2012/02/20 to 2008/01/11 is 1501&amp;nbsp; months&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 12.0pt;"&gt;&lt;TD height="16" style="height: 12.0pt;"&gt;From 2012/02/20 to 2008/02/13 is 1468&amp;nbsp; months&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 12.0pt;"&gt;&lt;TD height="16" style="height: 12.0pt;"&gt;From 2012/02/20 to 2008/03/21 is 1431&amp;nbsp; months&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it would appear that the 'MM' parameter in Interval#() gives days.&amp;nbsp; How this could possibly be a good idea, I do not know.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even more bizzarely, the simpler expression "=Interval#(Today() - Date([Set up date]), 'MM')" returns 2,617 in every row, even when the more elaborate expression get different numbers from the very same Interval() call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Screenshot - Interval().png" class="jive-image" src="https://community.qlik.com/legacyfs/online/11456_Screenshot+-+Interval%28%29.png" /&gt;&lt;/P&gt;&lt;P&gt;Is this all an experiment by the Great Old Ones to drive us mad?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 16:21:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296937#M495861</guid>
      <dc:creator />
      <dc:date>2012-02-20T16:21:58Z</dc:date>
    </item>
    <item>
      <title>How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296938#M495862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Jonathan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now you have the rule: "Any day in February to any day in March is one month; any day in March to any other day in March is zero months, etc".&amp;nbsp; My initial understanding was quite different...&lt;/P&gt;&lt;P&gt;I think it makes sense to &lt;STRONG&gt;assign unique sequence numbers to the months in the master calendar&lt;/STRONG&gt;.&amp;nbsp; It will help to calculate the difference on the front end.&lt;/P&gt;&lt;P&gt;As for the interval# using 'MM" - don't expect it to work.&amp;nbsp; It accepts DD, hh, mm, and ss, unless there were some recent additions. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 16:30:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296938#M495862</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-02-20T16:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296939#M495863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was hoping to avoid that, since it adds one more megabyte of data (assuming 50% compression) to an average file.&amp;nbsp; Since monthly calculations don't come up very often, I'm leaning toward Rob's solution of a &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Re: the use of "MM": thanks for spelling that out.&amp;nbsp; The QV10 doc only gives the examples "YY-MM-DD", "hh:mm:ss", "D hh:mm", but is not explicit about how the codes are interpreted.&amp;nbsp; It seems the answer is "the number of days between the dates."&amp;nbsp; Except when it's not.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 16:40:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296939#M495863</guid>
      <dc:creator />
      <dc:date>2012-02-20T16:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296940#M495864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah, my faith is pretty much curled up a corner sobbing by now.&amp;nbsp; Your solution is very graceful though, and it raises a productive avenue I'll try to keep in mind in the future (UDFs).&amp;nbsp; The only thing that concerns me is explaining to the users that this method has to be called with the $(...) surround.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The parentheses in your function were making my eyes cross, so I simplified it slightly:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;SET MonthDiff=(Year($1)*12 + Month($1) - (Year($2)*12 + Month($2)));&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Called as such:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;=$(MonthDiff(Today(), [Set up date]))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT: For consistency with similar functions in RDMSs, it would probably be better to express the logic as parameter B - parameter A, or putting it another way, "how many months passed from A to B?".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;SET MonthDiff=(Year($2)*12 + Month($2) - (Year($1)*12 + Month($1)));&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Results:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;=$MonthDiff('2000-01-01', '2012-02-20') = 145&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Too bad QlikView doesn't support method overloading, or we could have a single-param version which used Today() for the second parameter implicitly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 16:47:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296940#M495864</guid>
      <dc:creator />
      <dc:date>2012-02-20T16:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296941#M495865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can provide for an optional second parameter with a default of today like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;SET MonthDiff=(if(len($2)=0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;,(year(today(2))*12)+month(today(2))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;, (year($2)*12)+month($2))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;) - ((year($1)*12)+month($1));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;I'll leave it to you to improve the parens &lt;/SPAN&gt;&lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://robwunderlich.com"&gt;http://robwunderlich.com&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 07:44:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296941#M495865</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2012-02-21T07:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296942#M495866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jonathan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I always work with the30.4 as divider. This is the average nr of days per month in a year. I did not find any miscalculation so far. &lt;/P&gt;&lt;P&gt;t1:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; round((EndDate - StartDate)/30.4) as months&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;load&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; makedate(2012,01,01) as StartDate,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; makedate(2012,2,01) as EndDate&lt;/P&gt;&lt;P&gt;autogenerate (1) ; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 11:04:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296942#M495866</guid>
      <dc:creator />
      <dc:date>2012-02-21T11:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296943#M495867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;February 29th to April 1st is 32 days, but two months.&amp;nbsp; Your calculation would give 1.05, which would round to one.&amp;nbsp; You cannot calculate the number of months between two days with the number of days between them, just as you cannot calculate the number of days between two dates when given the month and day alone.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 15:32:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296943#M495867</guid>
      <dc:creator />
      <dc:date>2012-02-21T15:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296944#M495868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In that case I would use monthstart for both dates&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 15:46:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296944#M495868</guid>
      <dc:creator />
      <dc:date>2012-02-21T15:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296945#M495869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's close, but it's still an approximation.&amp;nbsp; A quick test shows that from 2000/03 to 2029/02 is 347 months, but that math gives 348: 10,564 days / 30.4 = 347.5.&amp;nbsp; That assumes that the rounding function used rounds 0.5 up; if it rounds down, there will be other errors.&amp;nbsp; Using the more exact figure of 30.438333 helps, but I'd be more comfortable using a calculation which is algorithmically correct rather than risk getting incorrect results at some point.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 16:10:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296945#M495869</guid>
      <dc:creator />
      <dc:date>2012-02-21T16:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296946#M495870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's a somewhat more compact version of my previous solution allowing an oprional second parm using ALT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;SET MonthDiff=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;( &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;(year(alt($2,today(2)))*12) + (month(alt($2,today(2))))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;- ((year($1)*12)+month($1));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 18:43:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296946#M495870</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2012-02-21T18:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: How Do I Get the Number of Months Between Two Dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296947#M495871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Excellent &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;On Feb 22, 2012 12:14 AM, "Rob Wunderlich" &amp;lt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 19:22:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-Do-I-Get-the-Number-of-Months-Between-Two-Dates/m-p/296947#M495871</guid>
      <dc:creator />
      <dc:date>2012-02-21T19:22:38Z</dc:date>
    </item>
  </channel>
</rss>

