1. Create a Date Prompt with a name "FromDate".
2. Create a "HTML Item" and place it right side of Date Prompt.
3. Double Click the HTML Item and place the below Code.
<script>
function subtractDay ()
{
var dtToday = new Date(); // returns current date and time and assign the value to the variable dtToday
var dtYesterday = new Date( dtToday - 86400000 ); // 86400000 = 24 hours * 60 (minutes per hour) * 60 (seconds per
minute) * 1000 (milliseconds per second)
var strYesterday = [dtYesterday.getUTCFullYear(), dtYesterday.getMonth()+1, dtYesterday.getDate()].join("-");
return strYesterday;
}
pickerControlFromDate.setValue( subtractDay() );
</script>
4. Click Ok and close the HTML Item.
5. Run the report and see yesterday's date appears in Date Prompt by default.
2. Create a "HTML Item" and place it right side of Date Prompt.
3. Double Click the HTML Item and place the below Code.
<script>
function subtractDay ()
{
var dtToday = new Date(); // returns current date and time and assign the value to the variable dtToday
var dtYesterday = new Date( dtToday - 86400000 ); // 86400000 = 24 hours * 60 (minutes per hour) * 60 (seconds per
minute) * 1000 (milliseconds per second)
var strYesterday = [dtYesterday.getUTCFullYear(), dtYesterday.getMonth()+1, dtYesterday.getDate()].join("-");
return strYesterday;
}
pickerControlFromDate.setValue( subtractDay() );
</script>
4. Click Ok and close the HTML Item.
5. Run the report and see yesterday's date appears in Date Prompt by default.
what about today`s date as default date?
ReplyDelete