on 06-11-2009 2:46 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.