COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: cac416 on 21 Jan 2009 03:16:39 PM

Title: Question about using the 'Age' function
Post by: cac416 on 21 Jan 2009 03:16:39 PM
I used the 'age' function which will return a value between a dob and current date.  The format of the value is yymmdd.  I can see the age in years is correct and I want to pull that out so I have a two digit age.  If I use the 'years between' to calculate, the ages are incorrect by one year (most of them).

How do I pull out just the years?

Any ideas?

Thanks!!
Title: Re: Question about using the 'Age' function
Post by: Rajaggopal on 23 Jan 2009 01:44:03 AM
Hi,
Try using this expression to pull out just the years.

cast( ([Data Item]/10000), integer)

Assuming the date range returned is either a 6 digit number or a 5 digit number... This should return only the quotient value which would be the number of years...

P.S: I tried to find any difference between the years obtained using age and years_between and i cudnt find one... Can you please post some sample DOB values for which these values differ?
Title: Re: Question about using the 'Age' function
Post by: ajaju on 27 Jan 2009 04:54:25 AM
Hi,

You can also try using this expression

(integer(substr(char(_age(Patient Date of Birth)),1,4)))

This will first give you the age.Then to get the first two digit from the age you need to use 'substr' function.