COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: sashafay on 28 Feb 2011 04:41:36 PM

Title: Dynamically define day of the month
Post by: sashafay on 28 Feb 2011 04:41:36 PM
How can I get dynamically define day of the month? For example get always 10th of each month and use it as part of the report filter, i.e. on February 28th it will return February 10th, on March 5th filter will use February 10th again, but on March 11th, report will be running with March 10th. Can I do this with Cognos built-in function? If not, SQL will work as well.

Hope that clear...  :-\
Title: Re: Dynamically define day of the month
Post by: PRIT AMRIT on 28 Feb 2011 10:44:32 PM
Create a DATA ITEM as [Current Date]

cast(case when extract(day,current_date) >10
then extract(year,current_date)*10000+extract(month,current_date)*100+10
else extract(year,_add_months(current_date,-1))*10000+extract(month,_add_months(current_date,-1))*100+10
end,date)

In filter: [DATE]=[Current Date]
[DATE] is your table date column.

Does this make sense?

Thanks
Prit
Title: Re: Dynamically define day of the month
Post by: sashafay on 28 Feb 2011 11:20:38 PM
Yes it does, except small thing: you got me SQL Server syntax and I'm in Oracle shop here. I maybe able to convert it to Oracle SQL, but anyway... Thank you! :D
Title: Re: Dynamically define day of the month
Post by: PRIT AMRIT on 28 Feb 2011 11:25:32 PM
If Oracle, Instead of Cast you can use to_date... and rest should remain same...