COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: 4eversonic on 04 Oct 2013 07:45:08 AM

Title: Default date prompt (last month)
Post by: 4eversonic on 04 Oct 2013 07:45:08 AM
Hello!

I have a requirement to force a date prompt in Report Studio to default to the last day of the prior month. Looking at some search results on Google, it appears I have to inssert an HTML script next to the prompt, but I can't seem to get any of the examples to work. Has anyone been successful with this?

Thanks!
Title: Re: Default date prompt (last month)
Post by: 4eversonic on 04 Oct 2013 08:26:59 AM
Hi everyone,

I found some Java script that seems to work. After adding the date prompt to the prompt page, you'll need to add an HTML item right next to it and add the following script:

<script language="javascript">
//Default date contains current month/year, so set day = 1
var dDate = new Date();
dDate.setDate(1);
//This goes back to last day of previous month
dDate.setDate(dDate.getDate()- 1);
pickerControlEndDate.setValue(getFormatDate(dDate, 0 , 'YMD'));
</script>

From there, you'll need to rename the prompt to EndDate. Seesm to work for me.

Thanks!