Default date prompt behavior in a report


Requirement: For a month to day report, always default the Start Date prompt to the first of the month
Step 1: Create a Time & Date prompt on the prompt page
Step 2: Give the prompt a specific name (ex: StartDate in this example)

Step 3: Drag an HTML item to the right of the prompt as shown below

Step 4: Paste the following script into the HTML Item
<script type = "text/javascript">
// Function returns the first day of the month for the current month
function MonthFirstDay ()
{
// Create a new variable to store today's date
var vCurrDate = new Date();
// Truncate the date to first of the month of this year
var vFirstDay = new Date(vCurrDate.getFullYear(), vCurrDate.getMonth(), 1);
// Convert the date in vFirstDay variable to a string value
var vStrDay = [vFirstDay.getUTCFullYear(), vFirstDay.getMonth()+1, vFirstDay.getDate()].join("-");
// Return the date
return vStrDay ;
}
// Function returns the time entered in the variable Time
function SetTime ()
{
var vTime = "09:00:00.000" ;
return vTime;
}
pickerControlStartDate.setValue( MonthFirstDay() );
timePickerStartDate.setValue( SetTime() );
</script>

Step 5: Replace StartDate (Bolded above) to the name of your prompt
Step 6: Run the report, and the result should be similar to


Comments

  1. hi there,

    we are usin a date prompt with range set to yes -do you knwo of a way to modify this (or another way) do default the query to the current month?

    ReplyDelete
  2. sorry query should be prompt - default the date prompt so the To is the first day of the current month and the from is the last day of the current month

    ReplyDelete
  3. It would be tricky. Le me look into it and get back to you.

    ReplyDelete

Post a Comment

Popular posts from this blog

RSV-VAL-0032 expression is not valid. If the item exists in a query but is not referenced in the layout, add it to a property list. CRX-API-0005 An error ocurred at or near the position '0'.

How can you extract all user information from Cognos Access Manager Namespace Report Utility and create Cognos Report out of it?

BME-EX-0047 Unable to read preferences for the requested interface..