COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: Sudha on 16 Nov 2007 07:30:04 AM

Title: How to ??
Post by: Sudha on 16 Nov 2007 07:30:04 AM
Hi all,
Does any one know how to produce the following format for Age from this calculation:

Age = Current_Date - Birth_Date

Age is presented in years and months, where the month range is from 0 through 11. Example: 52 years and 11months is formatted as 52.11 on the report.

TIA
Title: Re: How to ??
Post by: MFGF on 19 Nov 2007 04:52:27 AM
Hi,

Subtracting two dates like this results in an interval (days,hours,minutes,secs).  What you need instead is a YMDInterval (years,months,days).  If you need to specify both dates, try using the _ymdint_between() function to produce a ymdinterval, then use the extract() function to get hold of the year part, extract() again for the month, then drop these two into you report (list column) with a '.' text item between them.
Alternatively, if you always want to find out age based on the current date, use the age() function to produce your ymdinterval - you only need to specify your Birth Date as an argument.  Again, use extract() to pull out the year and month from the result.

Regards,

MF.

Regards,

MF.