Home
Analytics
Dynamic date on Plateau Report Designer 4.4.1
hossain_z
<p>Hello Experts,</p>
<p>I am trying to default date dynamically so I can use it in "select" query for comparison. I want to run the report 1st of every month to pull the history two months prior. So for example, in 1st April of 2016 It would pull only courses completed for February 2016.I am planning to use JavaScript to get first and last day of February 2016 dynamically based on the run date of the report.</p>
<p> </p>
<p> </p>
<p> </p>
<p>Thanks in advance!</p>
<p> </p>
<p>Z..</p>
<p> </p>
Find more posts tagged with
Comments
pricher
<p>Hi,</p>
<p> </p>
<p>You can script the start and end date parameters in the data set the following way:</p>
<p> </p>
<p>1. For the start date parameter:</p>
<pre class="_prettyXprint _lang-js">
var runDate = params["runDate"].value
var year = BirtDateTime.year(runDate)
var month = BirtDateTime.month(runDate)
if (month >= 3) {
startDate = BirtDateTime.date(year,month-3,1);
}
else if (month == 2) {
startDate = BirtDateTime.date(year-1,11,1)
}
else {
startDate = BirtDateTime.date(year-1,10,1)
}
startDate;
</pre>
<p>2. For the end date parameter:</p>
<pre class="_prettyXprint _lang-js">
var runDate = params["runDate"].value
var year = BirtDateTime.year(runDate)
var month = BirtDateTime.month(runDate)
if (month >= 3) {
endDate = BirtDateTime.date(year,month-3,BirtDateTime.day(BirtDateTime.addDay(BirtDateTime.date(year,month-2,1),-1)))
}
else if (month == 2) {
endDate = BirtDateTime.date(year-1, 11, 31)
}
else {
endDate = BirtDateTime.date(year-1,10,30)
}
endDate;
</pre>
<p>I have attached a sample report based on Classic Models.</p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>
shamo
<p>you can also add this to your select query</p>
<p>datefield between add_months(current_Date, -2) and add_months(current_Date, -1) in this case it will always pull the prior month date without using parameters.</p>