<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Hello, Can someone recommend the best way of calculating age in years, mont</title><link>https://community.appian.com/discussions/f/rules/4622/hello-can-someone-recommend-the-best-way-of-calculating-age-in-years-mont</link><description>Hello, Can someone recommend the best way of calculating age in years, months and days, by taking only a birth date / start date? Taking into consideration leap years and difference in days of the month, as they might be 28,29,30 or 31 days. Example input</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Hello, Can someone recommend the best way of calculating age in years, mont</title><link>https://community.appian.com/thread/81455?ContentTypeID=1</link><pubDate>Sat, 08 May 2021 11:52:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:78b5638d-bf77-4677-9861-bf7d89155fac</guid><dc:creator>Anurag</dc:creator><description>&lt;p&gt;I have created expression rule to calculate&amp;nbsp;age (in year) based&amp;nbsp;on birth date. Below is for reference, can be modified further to get month and days also:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;if(&lt;br /&gt; month(today())&amp;gt;month(ri!dob),&lt;br /&gt; year(today())-year(ri!dob),&lt;br /&gt; if(&lt;br /&gt; month(today())&amp;lt;month(ri!dob),&lt;br /&gt; year(today())-year(ri!dob)-1,&lt;br /&gt; if(day(today())&amp;lt;day(ri!dob),&lt;br /&gt; year(today())-year(ri!dob)-1,&lt;br /&gt; year(today())-year(ri!dob)&lt;br /&gt; ) &lt;br /&gt; )&lt;br /&gt;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hello,&lt;br /&gt;Can someone recommend the best way of calculating age in years, mont</title><link>https://community.appian.com/thread/16735?ContentTypeID=1</link><pubDate>Mon, 06 Apr 2015 10:37:31 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fd5ea7ab-724a-4360-9858-001cac5d3ab3</guid><dc:creator>PhilB</dc:creator><description>No problem!&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hello,&lt;br /&gt;Can someone recommend the best way of calculating age in years, mont</title><link>https://community.appian.com/thread/16734?ContentTypeID=1</link><pubDate>Mon, 06 Apr 2015 10:18:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b106718d-1ad7-423a-a818-290863859a55</guid><dc:creator>Adel Ammari</dc:creator><description>Thank you all for your snippets, i will study their logic for maximum benefit. philb, a special thank you goes to you as your snippet solved the issue for me in full, your code worked perfectly.&lt;br /&gt;&lt;br /&gt;Thanks a lot.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hello,&lt;br /&gt;Can someone recommend the best way of calculating age in years, mont</title><link>https://community.appian.com/thread/16733?ContentTypeID=1</link><pubDate>Mon, 06 Apr 2015 09:37:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ac70b004-2b04-41fb-b13a-f5b19e7b864e</guid><dc:creator>radhaa</dc:creator><description>I got the result as you specified, but its different approach. Please see the attached code fragment.&lt;br /&gt;&lt;p&gt;&lt;a href="/cfs-filesystemfile/__key/communityserver-discussions-components-files/15/Date-in-text-words"&gt;Date in text words&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hello,&lt;br /&gt;Can someone recommend the best way of calculating age in years, mont</title><link>https://community.appian.com/thread/16731?ContentTypeID=1</link><pubDate>Mon, 06 Apr 2015 01:17:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fca7fb74-d5be-4690-97c4-e8cc0b45c013</guid><dc:creator>PhilB</dc:creator><description>I have a feeling (although I haven&amp;#39;t tested it) that conor&amp;#39;s example might oversimplify this and won&amp;#39;t be quite right for certain dates - either that, or I&amp;#39;m overcomplicating it. Either way, feel free to copy the attached SAIL into the interface designer and hopefully it&amp;#39;ll help in some way.&lt;br /&gt;&lt;p&gt;&lt;a href="/cfs-filesystemfile/__key/communityserver-discussions-components-files/15/dateOfBirth.txt"&gt;dateOfBirth.txt&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hello,&lt;br /&gt;Can someone recommend the best way of calculating age in years, mont</title><link>https://community.appian.com/thread/16730?ContentTypeID=1</link><pubDate>Mon, 06 Apr 2015 00:04:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:cfb3bf17-50b9-4026-b2e7-8768ebb337f8</guid><dc:creator>Conor Cahill</dc:creator><description>You&amp;#39;re going to use the year(), month(), and day() functions to get the differences between the 2 dates. So you&amp;#39;ll get this:&lt;br /&gt;local!yearDiff: 1,&lt;br /&gt;local!monthDiff: -6,&lt;br /&gt;local!dayDiff: 1&lt;br /&gt;&lt;br /&gt;Now, you&amp;#39;ll check local!monthDiff. If it is negative, you subtract 1 from local!yearDiff, then add it to 12 (e.g. 12 + (-6)), and set that as the new month value. Then check local!dayDiff. If that is negative, you&amp;#39;ll subtract 1 from local!monthDiff. Here&amp;#39;s the tricky part, you need to figure out the number of days in the month immediately preceding the end date. &lt;br /&gt;&lt;br /&gt;To do this, use day(eomonth(ri!endingDate),-1). This will get the last day of the previous month. Add this to local!dayDiff (in your example you can skip all of the day-related calculation because local!dayDiff is positive.&lt;br /&gt;&lt;br /&gt;Now you have the 3 numbers, and all that&amp;#39;s remaining is to concatenate them into a string:&lt;br /&gt;&lt;br /&gt;local!yearDiffFinal &amp;amp; &amp;quot; years &amp;quot; &amp;amp; local!monthDiffFInal &amp;amp; &amp;quot; months &amp;quot; &amp;amp; local!dayDiffFinal &amp;amp; &amp;quot; days&amp;quot;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>