Tuesday, 16 September 2014

Cognos: Age calculation

We have two ways to calculate age in years and age in yy years mm months and dd days format
Calculate Age in years…
Create a query Calculation as below…
_years_between (current_date, [Birth date column])
Calculate Age in yy years, mm months and dd days format…
(replace [Birth Date] with your own Data of birth column)
substring (cast(_ymdint_between (current_date, [Birth date]),char(6)),1,2) || ‘ Years ‘||
substring (cast(_ymdint_between (current_date, [Birth date]),char(6)),3,2)
|| ‘ months ‘ ||
substring (cast(_ymdint_between (current_date, [Birth date]),char(6)),5,2)
|| ‘ Days ‘

No comments:

Post a Comment