cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Number of days to date in XI

former_member187447
Participant
0 Kudos

Hi

I have a scenario where in i have add the number days to date.

ex: if the date is 02092009 and if the days is 30. then the result of adding days to the date should be 02102009.

Do we have any readily available UDFs in XI if not it would be appreciated if i can get some procedure to implement this.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Dear Kalyan,

try with the following UDF and let me know in case of any issues;

try

{

Date dat = new SimpleDateFormat("ddMMyyyy").parse(a[0]);

Calendar cal = new GregorianCalendar();

cal.setTime(dat);

cal.add(Calendar.DAY_OF_MONTH, +cnt[0]);

Date bar = cal.getTime();

String expDate = new SimpleDateFormat("ddMMyyyy").format(bar);

result.addValue(expDate);

}

catch(Exception ex)

{

System.out.println(ex);

}

Note:

====

a[0] and cnt[0] are the two input values to the UDF.

a[0] --> date

cnt[0] --> days of the date

Former Member
0 Kudos

Hi ,

you can use this code in user defined function

Calendar cal = Calendar.getInstance();

/* here u can parse the individual values for year month and day, other calendar function are also available .*/

cal.set(1999,11,28);

/* here instead of value 30 u can pass the specific node integer value to add the no of days.*/

cal.add(Calendar.DATE, 30);

return cal.getTime().toString();

Regards,

Syed

former_member200962
Active Contributor
0 Kudos

Check if you want to implement a solution like the one mentioned in this discussion:

Regards,

Abhishek.

Former Member
0 Kudos

Hi

No Standard function given by SAP XI, need to built our own UDF to acheive this

rgds

srini