Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3576

Re: Dynamic Dates in Design Studio

$
0
0

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


Viewing all articles
Browse latest Browse all 3576

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>