Posts Tagged ‘Cognos 10’

Default Value in Date & Time Prompts

February 24, 2012

 To set the default value of a date prompt to yesterday’s date – or to any other date- you can use a javascript in the prompt page. IBM provides a small javascript code that you can use:
<script>
function subtractDay ()
{
var dtToday = new Date();
var dtYesterday = new Date( dtToday – 86400000 );

// NOTE 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;
}
function subtractTime ()
{
var Time = “08:00:00.000”;
return Time;
}
pickerControlPDateTime.setValue( subtractDay() );
timePickerPDateTime.setValue( subtractTime() );
</script>

You can also change the number of milliseconds and use the code for other relative dates. The problem with code is when you try to schedule the report with default value “yesterday” the code will not be executed. I will show you how to solve that issue in the next post.

Cognos 10

October 23, 2010

Ready for Cognos 10?