Dynamic Dates in Design Studio
I am new to SAP BO Design Studio.I have a start date ,end date,calendar date,current date,and have a from and to date propmts in the report.
I have to show by default 3 months data.I need this to dynamically change the current date and its previous 3 months.After that according to the strt date nd end date that is being selected,chart should get filtered.
How can I achieve this? I have referred How to use arrays for finding trailing months.
If I understand your scenario properly, your req is
Current date - 2015-11-04
you need to show by default From: 2015-09-04 TO:2015-11-04
In order to do this you can easily find the prev month and prev-1 month using the following logic.
All you need to do is take out the MM from your current date YYYY-MM-DD
So use a substring and get MM (this will be 11 in our scenario)
Now you need to find the prev month and its prev month
i will use the following local variable for explanation
So now you have currentdate YYYY-MM-DD
Using Substring split them to YYYY , MM , DD
and convert them to integers and store them into the local variables
Now check the following
if(currentmonth==2) /* if it is February the prevmonth2 will be in the prev year */
else if(currentmonth==1) /*If it is Jan , the prevmonth1 and prevmonht2 will be in the prev year */
var Fromdate = year+"-"+prevmonth2+"-"+date;
Use filter now
I hope this helps