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">
<script type = "text/javascript">
// Function returns the first day of
the month for the current month
function MonthFirstDay ()
{
function MonthFirstDay ()
{
// Create a new variable to store
today's date
var vCurrDate = new 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);
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("-");
var vStrDay = [vFirstDay.getUTCFullYear(), vFirstDay.getMonth()+1, vFirstDay.getDate()].join("-");
// Return the date
return vStrDay ;
}
return vStrDay ;
}
// Function returns the time entered
in the variable Time
function SetTime ()
{
var vTime = "09:00:00.000" ;
return vTime;
}
function SetTime ()
{
var vTime = "09:00:00.000" ;
return vTime;
}
pickerControlStartDate.setValue(
MonthFirstDay() );
timePickerStartDate.setValue( SetTime() );
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
hi there,
ReplyDeletewe 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?
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
ReplyDeleteIt would be tricky. Le me look into it and get back to you.
ReplyDelete