Skip to Content
0
Former Member
Jul 14, 2014 at 04:12 PM

Convert DOB to display age in years & months, then filter rules by age range

164 Views

I want to display client's age in years and months. I'm using the following stock code I found applied to the Format Formula directly on the data field:

if 
//months
(datediff('yyyy',{CDCLIENT.DOB},currentdate)-(if datepart('y',currentdate)>datepart('y',{CDCLIENT.DOB}) then 0 else 1))<2 then
totext(datediff('m',{CDCLIENT.DOB},currentdate),0,'') & ' months'
else
//years
totext((datediff('yyyy',{CDCLIENT.DOB},currentdate)-(if datepart('y',currentdate)>datepart('y',{CDCLIENT.DOB}) then 0 else 1)),0,'') & ' years'

It does a successful job at displaying the age in general (i.e. 25 years). However, for our state reporting project, we have to separate our data from clients who reach the age threshold 20 yrs 7 months. The report will end up being two reports (or possibly just re-ran with a select expert display parameter): 1) Youth 2) Adult. The youth will be below 20 yr 7 mos and the Adult will be the opposite.


What would the best way to build this?