COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: Nandini.t on 29 Dec 2011 12:41:32 AM

Title: months between two dates
Post by: Nandini.t on 29 Dec 2011 12:41:32 AM
hi all,

How to get months between two dates which is in the format yyyy/mm.
eg : 2003/08 and 2000/12


Thanks for any help in advance....
Title: Re: months between two dates
Post by: HalfBloodPrince on 29 Dec 2011 02:03:10 AM
what you want to calculate No. of months between two dates(Difference) or Month Names between this two Dates ?
Title: Re: months between two dates
Post by: Nandini.t on 29 Dec 2011 02:49:37 AM
No. of months between two dates(Difference)
Title: Re: months between two dates
Post by: blom0344 on 29 Dec 2011 03:42:59 AM
A relative easy calculation would be to take the year part of the item  , multiply this by 12 and add the month value. Subtracting these 2 values would yield the difference in months.

Assuming the item is in string format:

cast(substring([someitem],1,4),integer)*12 + cast(substring([someitem],6,2),integer)

2003/08  would yield: 24044
2000/12 would yield:  24012

difference =  24044-24012  =  32 months

Title: Re: months between two dates
Post by: barrysaab on 29 Dec 2011 03:59:18 AM
Thanks,blom0344,What if it is Month Names between this two Dates ?
Title: Re: months between two dates
Post by: blom0344 on 29 Dec 2011 06:28:57 AM
A difference would yield a numerical value. I honestly do not understand your question. Please elaborate !!
Title: Re: months between two dates
Post by: MFGF on 29 Dec 2011 11:42:15 AM
Do you mean you want to supply two dates and see all the months between those two dates displayed? If so, you need to display the Month item in your report, and add a filter which prompts for the start date and end date required.

Regards,

MF.