cancel
Showing results for 
Search instead for 
Did you mean: 

date mapping

Former Member
0 Kudos

hi masters,

I have a problem regarding date mapping. How can I add 1 day to a given date. For example, I have a 20090630 date. That's June 30, 2009. How can I add 1 day to it so that the resulting value will be 20090701? If I just use 'add constant 1', the resulting value will be 20090631. There's no 31 for June.

Thanks!

regards,

IX

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

You can write a UDF where you can Pass the Current Data available in the Standard Functions and can get the next date.The UDF may look like :

import java.util.*;

import java.text.*;

// Import statements

int Millisecs = 1000 * 60 * 60 * 24;

SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yy");

//You can specify your date format

Date date = new Date();

String nextDate = dateFormat.format(date.getTime() + Millisecs);

// ( return this string in your UDF)

Hope this will help.

Thanks

Ajay

Former Member
0 Kudos

hi sir ajay,

I have an input if im going to use a UDF. I will not use the current date. the input date is in YYYYMMdd format.

Answers (1)

Answers (1)

Former Member
0 Kudos

try {

Date sdate = new SimpleDateFormat("yyyy-MM-dd").parse(a); // converting string to date format

int dd = sdate.getDate();

int mm = sdate.getMonth();

int yy = sdate.getYear();

dd = dd + 1; // add one day

Date afterOneDay = new Date (yy,mm,dd);

a = new SimpleDateFormat("yyyy-MM-dd").format(afterOneDay); // converting date to string & return

return a;

}

catch(Exception e) {

return e.toString();

}

Note : The following paramters to be entered in imports text area field.

java.util.Date;java.text.SimpleDateFormat;