Hi Everyone,
How can I set the Date Prompt default to yesterday's date instead of today?
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)
Thank you, KC9400. I appreciate it.
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.
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....
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);
pickerControl
Date_P.setValue(getFormatDate(dDate, 0 , 'YMD'));
</script>
I appreciate your response
Thanks
Inam
Hi Inu,
Were you able to solve the problem? I also need to set Yesterday as default in date prompt.
Thanks!! in advance
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?