<?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 Age in Year Month Day Format in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Age-in-Year-Month-Day-Format/m-p/346945#M128348</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Please give me some ideas about how to calculate Age for Patient in the hospital by using Visit Hospital Date - Date of Birth &lt;/P&gt;&lt;P&gt;and the result should be Year, Number of Month , Day &lt;/P&gt;&lt;P&gt;such as &lt;/P&gt;&lt;P&gt;Date of Birth 01/01/2011&lt;/P&gt;&lt;P&gt;Visit Hospital Date 11/03/2012 &lt;/P&gt;&lt;P&gt;Age = 1 Year 2 Months 11 Days &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance for sharing....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 11 Mar 2012 13:45:22 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-03-11T13:45:22Z</dc:date>
    <item>
      <title>Age in Year Month Day Format</title>
      <link>https://community.qlik.com/t5/QlikView/Age-in-Year-Month-Day-Format/m-p/346945#M128348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Please give me some ideas about how to calculate Age for Patient in the hospital by using Visit Hospital Date - Date of Birth &lt;/P&gt;&lt;P&gt;and the result should be Year, Number of Month , Day &lt;/P&gt;&lt;P&gt;such as &lt;/P&gt;&lt;P&gt;Date of Birth 01/01/2011&lt;/P&gt;&lt;P&gt;Visit Hospital Date 11/03/2012 &lt;/P&gt;&lt;P&gt;Age = 1 Year 2 Months 11 Days &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance for sharing....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 11 Mar 2012 13:45:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Age-in-Year-Month-Day-Format/m-p/346945#M128348</guid>
      <dc:creator />
      <dc:date>2012-03-11T13:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Age in Year Month Day Format</title>
      <link>https://community.qlik.com/t5/QlikView/Age-in-Year-Month-Day-Format/m-p/346946#M128349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ainiko,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is a little complex using QV functions, but I think you can do it like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SET DateFormat='DD/MM/YYYY';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;INPUT:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD * &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;, if(day(VisitDay) &amp;gt;= day(DoB), &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; mod(MonthIDVisitDay-MonthIDDoB,12),&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; mod(MonthIDVisitDay-MonthIDDoB,12)-1) as AgeMonths&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;, if(day(VisitDay) &amp;gt;= day(DoB),&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; day(VisitDay)-day(DoB),&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; VisitDay-addmonths(DoB,12*AgeYears+mod(MonthIDVisitDay-MonthIDDoB,12)-1))+1 as AgeDays&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD *&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;, age(VisitDay,DoB) as AgeYears&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;, Year(DoB)*12+Month(DoB) as MonthIDDoB&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;, Year(VisitDay)*12+Month(VisitDay) as MonthIDVisitDay&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;INLINE [&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;DoB, VisitDay&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;01/01/2011, 11/03/2012&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;01/01/2010, 29/02/2012&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;01/03/2010, 29/02/2012&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;];&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just used a preceding load so I can use fields I calculated in the INLINE table load, this makes it somewhat easier to read.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe there is a VBScript function I don't know of you can call as Macro code from the script, but above should work using only QV functions.&lt;/P&gt;&lt;P&gt;The created Age fields can then easily be concatenated to a string like&lt;/P&gt;&lt;P&gt;&lt;EM&gt;=AgeYears &amp;amp;' Years '&amp;amp;AgeMonths&amp;amp;' Months '&amp;amp;AgeDays&amp;amp;' Days'&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the frontend or also as a new field, to get a string like you requested above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit: corrected bugs in AgeMonths and AgeDays&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit2: Corrected another bug when start and end date fall into the same calendar month.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 11 Mar 2012 16:23:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Age-in-Year-Month-Day-Format/m-p/346946#M128349</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-03-11T16:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: Age in Year Month Day Format</title>
      <link>https://community.qlik.com/t5/QlikView/Age-in-Year-Month-Day-Format/m-p/346947#M128350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much. It is helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2012 13:21:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Age-in-Year-Month-Day-Format/m-p/346947#M128350</guid>
      <dc:creator />
      <dc:date>2012-03-12T13:21:10Z</dc:date>
    </item>
  </channel>
</rss>

