Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Dynamic Dates in Design Studio

Hi everyone,

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.

Regards

Archana

Tags:
Former Member
Former Member replied

Hi Archana

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

currentmonth

prevmonth1

prevmonth2

currentyear

date

year

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

currentmonth=MM;

currentyear=YYYY;

date=currentyear;

Now check the following

if(currentmonth==2)   /* if it is February the prevmonth2 will be in the prev year */

{

prevmonth1=01;

prevmonth2=12;

year=currentyear-1;

}

else if(currentmonth==1)  /*If it is Jan , the prevmonth1 and prevmonht2 will be  in the prev year */

{

prevmonth1=12;

prevmonht2=11;

year=currentyear-1;

}

else

{

prevmonth1=currentmonth-1;

prevmonth2-currentyear-2;

year=currenyear;

}

var Fromdate = year+"-"+prevmonth2+"-"+date;

Use filter now

DS.setfilter(Datedimension,{"low":FromDate,"high":currentdate});

I hope this helps

Thanks

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question