Skip to Content
0

I need to have restrict data with radio buttons having buttons as last 30, 60, 90 and 180 days.

Sep 07, 2017 at 09:36 AM

61

avatar image
Former Member

I'm Ravi,

Using Design studio 1.6 sp00 and BO 4.1 SP08

I have used below code to get last 30 days data.

var date = APPLICATION.getInfo().dateNowInternalFormat;

var year = Convert.stringToInt(date.substring(0,4));

var month = Convert.stringToInt(date.substring(4,6));

var day = Convert.stringToInt(date.substring(6,8)) - 30;

var days = [0,31,28,31,30,31,30,31,31,30,31,30,31];

var leapYearOffset = 0;

if(day <= 0) {

month = month - 1;

if (month == 0) {

year = year - 1;

month = 12;

}

else if (month == 2) {

var quotient4 = -1;

var quotient100 = -1;

var quotient400 = -1;

var value = Convert.floatToString(year / 4);

quotient4 = Convert.stringToInt(value.substring(0,value.indexOf(".")));

value = Convert.floatToString(year / 100);

quotient100 = Convert.stringToInt(value.substring(0,value.indexOf(".")));

value = Convert.floatToString(year / 400);

quotient400 = Convert.stringToInt(value.substring(0,value.indexOf(".")));

if(((quotient4 * 4) == year && (quotient100 * 100) != year) || (quotient400 * 400) == year) {

leapYearOffset = 1;

}

}

day = day + days[month] + leapYearOffset;

}

var dayStr = day + "";

var monthStr = month + "";

if (dayStr.length == 1) {

dayStr = "0" + dayStr;

}

if(monthStr.length == 1) {

monthStr = "0" + monthStr;

}

date = year + monthStr + dayStr;

DATEFIELD_1.setDate(date);

Please help me to get date for 60 days and 90 days.

regards,

Ravi Bodala

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Mustafa Bensan Sep 07, 2017 at 10:52 AM
0

Hi Ravi,

I do not recommend implementing the complex scripting approach you have provided. You have already asked this question earlier and two solution options have been suggested: https://answers.sap.com/questions/299717/im-trying-to-restrict-date-with-number-of-days-by.html

Regards,

Mustafa.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks Mustafa,

I have delivery dead line by today for that I'm in hurry to find solution. so, I'm using solution with more complexities.

Thanks once again for helping.

Regards,

Ravi Bodala

0