<?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 to calculate number of years, months and days from number of days between 2 dates? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536070#M1226744</link>
    <description>&lt;P&gt;AFAIK there is no monthsbetween() implemented in Qlik (in opposite to tools like Oracle or SAP) - at least the Qlik help + community has no hint to it.&lt;/P&gt;&lt;P&gt;But with a parametrized variable an appropriate customized function could be created, maybe like:&lt;/P&gt;&lt;P&gt;set MonthsBetween = (year($1)*12+month($1))-(year($2)*12+month($2));&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Beside this returns this kind of solution a string - even if long versions with YEAR/MONTH/DAY(s) descriptions were skipped - which will need more resources (for the calculation and the storing) which would be probably not really essentially within the most scenarios but keeping the result numeric enables further other formatted versions as well as applying easy possibilities to group and cluster the date-offsets.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Nov 2025 07:12:58 GMT</pubDate>
    <dc:creator>marcus_sommer</dc:creator>
    <dc:date>2025-11-13T07:12:58Z</dc:date>
    <item>
      <title>How to calculate number of years, months and days from number of days between 2 dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536009#M1226732</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;for example, this expression "=today() - date(date#('20200920','YYYYMMDD'))"&lt;/P&gt;&lt;P&gt;returns 1879 as a result and I need to show number of years, months and days between those 2 dates.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 12 Nov 2025 13:54:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536009#M1226732</guid>
      <dc:creator>NenadV</dc:creator>
      <dc:date>2025-11-12T13:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate number of years, months and days from number of days between 2 dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536024#M1226733</link>
      <description>&lt;P&gt;Maybe with something like this:&amp;nbsp;&lt;A href="https://community.qlik.com/t5/QlikView-App-Dev/DATEDIFF-function-in-qlik-sense/td-p/2053996" target="_blank"&gt;Solved: DATEDIFF function in qlik sense - Qlik Community - 2053996&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Nov 2025 15:49:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536024#M1226733</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2025-11-12T15:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate number of years, months and days from number of days between 2 dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536025#M1226734</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/147573"&gt;@NenadV&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I would use this expression:&lt;SPAN&gt;&lt;!--ScriptorEndFragment--&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;=Date(num(today() - date(date#('20200920','YYYYMMDD'))+1),'YY/MM/DD')&lt;/P&gt;
&lt;P&gt;the result is 05/02/23 so 5 years 2 months and 23 days. Today is the 12th of November 2025, by the way.&lt;BR /&gt;The idea is to use the Num() function to write the difference between the dates in numeric format.&lt;BR /&gt;So the middle expression&lt;/P&gt;
&lt;P&gt;=num(today() - date(date#('20200920','YYYYMMDD'))+1&lt;/P&gt;
&lt;P&gt;calculates the number of days between the 2 dates, that is 1879 plus 1, that is 1880. I will explain later why I added 1.&lt;BR /&gt;You can then use the Date() function to transform this number of days in Years, Months and Days.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Notice that the value may be not fully accurate, because when you calculate Date(1879 +2 ,'YY/MM/DD') you are calculating what year, month and day is after the 1st of January 1900.&amp;nbsp; Considering that&amp;nbsp; not all the months have the same umber of days and that not all years have 365 days,&amp;nbsp; there may be up to 2 days (I think) difference with the real value. &lt;BR /&gt;Unfortunately I did not find how to get a more precise value.&lt;/P&gt;
&lt;P&gt;Ah, why did I add +1 in the formula? It's because QlikView and Qlik Cloud ( I think also Qlik Sense) start calculating dates from the 30/12/1899, so you need to add 1 day to start your date calculation from the first day of the century.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Nov 2025 16:01:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536025#M1226734</guid>
      <dc:creator>Andrea_Bertazzo</dc:creator>
      <dc:date>2025-11-12T16:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate number of years, months and days from number of days between 2 dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536033#M1226735</link>
      <description>&lt;P&gt;Great approach. But I think the logic needs a small adjustment because the date-difference of 1 will return 00/01/01 respectively 1 month and 1 day. Therefore I believe it should be rather look like:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;=Date(num(today() - date(date#('20200920','YYYYMMDD'))&lt;STRONG&gt;-30&lt;/STRONG&gt;),'YY/MM/DD')&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Nov 2025 17:05:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536033#M1226735</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2025-11-12T17:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate number of years, months and days from number of days between 2 dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536048#M1226742</link>
      <description>&lt;P&gt;Give a try using this approach&lt;/P&gt;&lt;P&gt;Floor(MonthsBetween([EndDate], [StartDate]) / 12) &amp;amp; ' Years, '&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // YEAR&lt;BR /&gt;&amp;amp; Floor(Mod(MonthsBetween([EndDate], [StartDate]), 12)) &amp;amp; ' Months, '&amp;nbsp;&amp;nbsp;// MONTH&lt;BR /&gt;&amp;amp; Floor([EndDate] - AddMonths([StartDate], Floor(MonthsBetween([EndDate], [StartDate])))) &amp;amp; ' Days'&amp;nbsp; &amp;nbsp;// DAYS&lt;/P&gt;&lt;DIV class=""&gt;Explanation of each element&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN class=""&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;STRONG&gt;MonthsBetween([EndDate], [StartDate])&lt;/STRONG&gt;&lt;/FONT&gt;: This function calculates the total number of full/partial months between the two dates. This determins the years and remaining months.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;Floor(MonthsBetween(...) / 12)&lt;/STRONG&gt;: This calculates the number of full years in the interval.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;Floor(Mod(MonthsBetween(...), 12))&lt;/STRONG&gt;: The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Mod&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;function finds the remainder after dividing the total months by 12, giving you the number of remaining months (0-11).&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;AddMonths([StartDate], ...)&lt;/STRONG&gt;: This function calculates a date that is the number of total months (calculated earlier) after the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;[StartDate].&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;[EndDate] - AddMonths(...)&lt;/STRONG&gt;: Subtracting the calculated date (after adding all the full months) from the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;[EndDate]&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;gives the number of remaining days.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Floor()&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;ensures a whole number of days.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;&amp;amp; ' ... ' &amp;amp;&lt;/STRONG&gt;: This concatenates the calculated numerical values with the descriptive strings (e.g., ' Years, ').&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Example&lt;/DIV&gt;&lt;DIV class=""&gt;If&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;[StartDate]&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is '2022-01-15' and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;[EndDate]&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is '2024-04-20', the expression would result in:&lt;BR /&gt;&lt;STRONG&gt;2 Years, 3 Months, 5 Days&lt;/STRONG&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 13 Nov 2025 00:44:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536048#M1226742</guid>
      <dc:creator>Luis_Galvan</dc:creator>
      <dc:date>2025-11-13T00:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate number of years, months and days from number of days between 2 dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536064#M1226743</link>
      <description>&lt;P&gt;I've never seen this smart approach before &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/48752"&gt;@Andrea_Bertazzo&lt;/a&gt;.&amp;nbsp;I will give it a try next time I run into a similar request.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Nov 2025 05:51:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536064#M1226743</guid>
      <dc:creator>Vegar</dc:creator>
      <dc:date>2025-11-13T05:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate number of years, months and days from number of days between 2 dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536070#M1226744</link>
      <description>&lt;P&gt;AFAIK there is no monthsbetween() implemented in Qlik (in opposite to tools like Oracle or SAP) - at least the Qlik help + community has no hint to it.&lt;/P&gt;&lt;P&gt;But with a parametrized variable an appropriate customized function could be created, maybe like:&lt;/P&gt;&lt;P&gt;set MonthsBetween = (year($1)*12+month($1))-(year($2)*12+month($2));&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Beside this returns this kind of solution a string - even if long versions with YEAR/MONTH/DAY(s) descriptions were skipped - which will need more resources (for the calculation and the storing) which would be probably not really essentially within the most scenarios but keeping the result numeric enables further other formatted versions as well as applying easy possibilities to group and cluster the date-offsets.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Nov 2025 07:12:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536070#M1226744</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2025-11-13T07:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate number of years, months and days from number of days between 2 dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536111#M1226745</link>
      <description>&lt;P&gt;It's really Great Approach.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Nov 2025 12:56:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536111#M1226745</guid>
      <dc:creator>Nagaraju_KCS</dc:creator>
      <dc:date>2025-11-13T12:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate number of years, months and days from number of days between 2 dates?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536135#M1226747</link>
      <description>&lt;P&gt;Totally correct. There is no fuction using this calculation in Qlik yet; however, your approach covers what the function usually does; therefore, it can be twist by using a variable like the one you shared.&lt;/P&gt;&lt;P&gt;Thank you for the catch!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Nov 2025 16:20:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-calculate-number-of-years-months-and-days-from-number-of/m-p/2536135#M1226747</guid>
      <dc:creator>Luis_Galvan</dc:creator>
      <dc:date>2025-11-13T16:20:38Z</dc:date>
    </item>
  </channel>
</rss>

