COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: jmills on 21 Jun 2012 11:52:03 AM

Title: Datediff rounding
Post by: jmills on 21 Jun 2012 11:52:03 AM
I'm trying to calculate the difference between two dates using the following statement: datediff({year}, [date X], [date Y])

Due to the fact that i'm interested in the difference in the number of years, the calculation neglects the current month, therefore a difference in years between 2000-12--01 and today 2012-06-21 = 12.... however the answer should be 11 as we haven't yet reached December.

Is there a way to incorporate the day/month into this calculation?

Thanks
Title: Re: Datediff rounding
Post by: jmills on 21 Jun 2012 03:04:09 PM
AHA!! I Found a slick solution!!!

datdiff({month}, [Date X], Date Y])12

basically, it finds the difference in the number of months, and divides by 12.