COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: elee123 on 11 Nov 2014 07:58:10 AM

Title: set default Date Prompt in Report Studio
Post by: elee123 on 11 Nov 2014 07:58:10 AM
Hi Everyone,

How can I set the Date Prompt default to yesterday's date instead of today?
Title: Re: set default Date Prompt in Report Studio
Post by: kc9400 on 11 Nov 2014 08:59:36 AM
If you place a HTML item to the right of your date prompt and insert the following:


<script language="javascript">
var dDate = new Date();
//Subtract one day
dDate.setDate(dDate.getDate()-1);
pickerControlName.setValue(getFormatDate(dDate, 0 , 'YMD'));
</script>



You'll have to set the "Name" of the date prompt to match what is put in the JS, I've placed the relevant part in BOLD. The name of the date prompt must match what you call it here.

Source: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014441492 (https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014441492)
Title: Re: set default Date Prompt in Report Studio
Post by: elee123 on 11 Nov 2014 09:40:12 AM
Thank you, KC9400. I appreciate it.
Title: Re: set default Date Prompt in Report Studio
Post by: jabs on 12 May 2015 03:34:26 PM
Mine wasn't working, so I went to the referenced link. One step was skipped, unless I misread something. Once I did the following, the JS script worked.

Add name to "Name" attribute of the date prompt.
Title: Re: set default Date Prompt in Report Studio
Post by: inu on 25 Aug 2016 03:29:28 AM
Quote from: kc9400 on 11 Nov 2014 08:59:36 AM
If you place a HTML item to the right of your date prompt and insert the following:


<script language="javascript">
var dDate = new Date();
//Subtract one day
dDate.setDate(dDate.getDate()-1);
pickerControlName.setValue(getFormatDate(dDate, 0 , 'YMD'));
</script>



You'll have to set the "Name" of the date prompt to match what is put in the JS, I've placed the relevant part in BOLD. The name of the date prompt must match what you call it here.

Source: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014441492 (https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014441492)




Hi Team,

I used same js code, and set the name of Date prompt to the code. still not working ... can you please tell me , why not working....

Title: Re: set default Date Prompt in Report Studio
Post by: inu on 25 Aug 2016 06:02:55 AM
Quote from: kc9400 on 11 Nov 2014 08:59:36 AM
If you place a HTML item to the right of your date prompt and insert the following:


<script language="javascript">
var dDate = new Date();
//Subtract one day
dDate.setDate(dDate.getDate()-1);
pickerControlName.setValue(getFormatDate(dDate, 0 , 'YMD'));
</script>



You'll have to set the "Name" of the date prompt to match what is put in the JS, I've placed the relevant part in BOLD. The name of the date prompt must match what you call it here.

Source: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014441492 (https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014441492)


See the attached file,, and let me know, where i am missing..

js code is as follows , i used

<script language="javascript">
var dDate = new Date();
//Subtract one day
dDate.setDate(dDate.getDate()-1);
pickerControlDate_P.setValue(getFormatDate(dDate, 0 , 'YMD'));
</script>


I appreciate your response


Thanks
Inam
Title: Re: set default Date Prompt in Report Studio
Post by: cognos3 on 28 Apr 2017 10:15:42 AM
Hi Inu,

Were you able to solve the problem? I also need to set Yesterday as default in date prompt.

Thanks!! in advance
Title: Re: set default Date Prompt in Report Studio
Post by: kc9400 on 01 Jun 2017 07:08:17 AM
Quote from: cognos3 on 28 Apr 2017 10:15:42 AM
Hi Inu,

Were you able to solve the problem? I also need to set Yesterday as default in date prompt.

Thanks!! in advance

Did you manage to get it working?