Adding Default dates based on current date in Canned Report

Hello Helical Insight,

I am using Helical Insight 4.0 RC2. I have a canned report in which I am using StartDate and EndDate as filters. I want the default value of StartDate to be the first of the current month and the EndDate to be the 30th of the current month. What changes do I need to make in the configuration?

Thanks,
kisekir.

Hello kisekir,

The default values of the parameters in canned reports is defined in the configuration section. This section uses javascript functions. In order to define the default StartDate as the first day of the month, you can use the following script in the configuration section:

var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();
var start_of_month = yyyy + '-' + mm + '-' + '01';
Dashboard.setVariable("pStartDate", start_of_month);

image

For making the default EndDate as 30th of the month, replace ‘01’ in the above script with ‘30’ as shown below:

var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();
var end_of_month = new Date(today.getFullYear(), today.getMonth()+1, 0);
Dashboard.setVariable("pEndDate", end_of_month);

image

Thanks,
Helical Insight.