COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: Annon on 16 Jul 2015 01:31:15 PM

Title: Date prompt using in_range function requires showing 1 month automatically
Post by: Annon on 16 Jul 2015 01:31:15 PM
Hi, I have a requirement of showing begin date as 16th July 2015 i.e. today's date and end date 16th of June 2015(exactly 1 month less) automatically in prompt page while using filter as [Date] in_range ?Start and End Date? in query. I am using Date prompt in my prompt page and mine is relational data base. It would be a big help if you can come up with some Java or HTML Scripts.
Title: Re: Date prompt using in_range function requires showing 1 month automatically
Post by: gpollock on 16 Jul 2015 01:53:04 PM
You'll use a filter expression to do this.  When editing your query filter, there is a built-in function to add/subtract days.  Use that to always get this day last month.
Title: Re: Date prompt using in_range function requires showing 1 month automatically
Post by: sacjeanie on 17 Jul 2015 06:10:28 PM
I would create two prompts with default values.

Data Item #1 - Today's date = {sysdate} (This is an Oracle function and we have an Oracle DB)

Data Item #2 - Year ago Date = _add_years ({sysdate}, -1) 
                  (or you could use the data item name you used from prompt #1)

There is some oddity on leap years on leap days that you have to take in account.