COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: cognos4all on 07 Dec 2011 04:07:42 PM

Title: Getting previous month date
Post by: cognos4all on 07 Dec 2011 04:07:42 PM
Hello,
I am trying to get the previous month date in Text item. I am setting the source type as report expression and on Report expression property i tried to calculate the date and doesn't seem to work. I tried _add_months function and getting syntax error. For example i tried these and didn't worked.
_add_months (_first_of_month (Today ()),-1)

_first_of_month(_add_months(current_date, -1))

When i run the report, i want to display previous month for example Nov 2011

I even tried to calculate the previous month in a query, but since the query is not associated with the text item, it won't allow me to attach the calculated data item to the text item.

Any help woud be very much appreciated.

Thanks
Title: Re: Getting previous month date
Post by: cognostechie on 07 Dec 2011 05:30:44 PM
Instaed of using a text Item, try using a Singleton, point that to the Query that has the calculation for last Month and then use that data item for last Item in that singleton.
Title: Re: Getting previous month date
Post by: cognos4all on 09 Dec 2011 09:33:06 AM
Thank you very much; it work's if we use singleton object.

Thanks again