cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Month Number to Month name in design studio 1.6

Former Member
0 Kudos

HI Experts,

I  am capturing Variable value in text box on top of landing page i have calendar year as a variable .i have in 003 2015 . format .my requirement is to convert oo3 in march i have worked  in 1.3   i believe there is no cast or date function .i am not sure about 1.6 .

var a = DS_2.getVariableValueText("PA_V_A_MM_YYYY");

LINE.setText("mEUR:" +a);

DS_2.loadDataSource();

I Have gone through below discussions but  doesnt full fill my requirement.could any guide me on this?

Any reply really appreciated

Thanks,

varun

Accepted Solutions (1)

Accepted Solutions (1)

MustafaBensan
Active Contributor
0 Kudos

Hi Varun,

Here is a compact coding option to meet your requirement in Design Studio 1.6, assuming the date format from your variable is "MMM YYY", as per your example of "003 2015":

var month = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];

var a = DS_2.getVariableValueText("PA_V_A_MM_YYYY");

var  monthNum = Convert.stringToInt(a.substring(0,3));

LINE.setText("mEUR:" + month[monthNum - 1]);

Regards,

Mustafa.

Former Member
0 Kudos

HI Mustafa,

Yes you are correct.

Code which you have given working great but i am able to see only month  name i need combination of month and year too(jun 2015)

and i am having date in below  format

Thanks,

Varun

MustafaBensan
Active Contributor

Hi Varun,

Try the following code update:

var month = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];

var a = DS_2.getVariableValueText("PA_V_A_MM_YYYY");

var  monthNum = Convert.stringToInt(a.substring(0,3));

var  Year = Convert.stringToInt(a.substring(4,8));

LINE.setText("mEUR:" + month[monthNum - 1] + " " + Year);

Regards,

Mustafa.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Varun,

First update your Design studio to 1.6 SP03 (latest version). so you will get one new function to capture system date i.e.{ APPLICATION.getInfo().dateNowInternalFormat }

I have written one code for my Dashboard which sharing with you. Please do necessary changes as per you requirement & it will work for you. 

Code :-

TEXT_1.setText(Convert.subString(APPLICATION.getInfo().dateNowInternalFormat,0,4)); 

var monthYear = Convert.subString(APPLICATION.getInfo().dateNowInternalFormat, 4,6);

var monthNum = Convert.subString(APPLICATION.getInfo().dateNowInternalFormat, 4,6); 

var monthStr3 = ""; 

var monthStrFull = ""; 

      if (monthNum == "01") {monthStr3 = ".01"; monthStrFull = "January";} 

else if (monthNum == "02") {monthStr3 = ".02"; monthStrFull = "February";} 

else if (monthNum == "03") {monthStr3 = ".03"; monthStrFull = "March";} 

else if (monthNum == "04") {monthStr3 = ".04"; monthStrFull = "April";} 

else if (monthNum == "05") {monthStr3 = ".05"; monthStrFull = "May";} 

else if (monthNum == "06") {monthStr3 = ".06"; monthStrFull = "June";} 

else if (monthNum == "07") {monthStr3 = ".07"; monthStrFull = "July";} 

else if (monthNum == "08") {monthStr3 = ".08"; monthStrFull = "August";} 

else if (monthNum == "09") {monthStr3 = ".09"; monthStrFull = "September";} 

else if (monthNum == "10") {monthStr3 = ".10"; monthStrFull = "October";} 

else if (monthNum == "11") {monthStr3 = ".11"; monthStrFull = "November";} 

else if (monthNum == "12") {monthStr3 = ".12"; monthStrFull = "December";} 

Xcal=(monthYear + monthStr3);

TEXT_2.setText(Xcal);

Still you facing issues then let me know, i will recode it as per your requirement.

Thanks!

Ketan

MustafaBensan
Active Contributor
0 Kudos

Hi Ketan,

My understanding is that Varun's requirement is to capture the date from a data source variable using getVariableValueText(), so the APPLICATION.getInfo().dateNowInternalFormat is not applicable as it returns the current system date and not the date from the data source variable.

Regards,

Mustafa.