on 08-26-2010 5:09 PM
Hi Guys,
Please can any one tell me how to add 7 days to the current date !!
Regards
Thanks
San
Hi.
For this requeriment you need to make an UDF.
for example you can use this.
import java.util.Date;
import java.util.Calendar;
Calendar today = Calendar.getInstance();
today.setTime("yourdate");
today.add(Calendar.DATE, 7);
return today.getTime();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ASandhya .
Use this .
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String strdate = "";
Calendar today = Calendar.getInstance();
today.add(Calendar.DATE, 7);
strdate = sdf.format(today.getTime());
return strdate;
....Did you put the class on import section?.
java.util.Date;java.util.Calendar;java.text.SimpleDateFormat;
Edited by: Luis Ortiz on Aug 26, 2010 12:02 PM
function myudf(Container container)
{
String today;
try {
String dt = "2010-01-01"; // Start date
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
today=sdf.format(calendar.getTime());
Calendar c = Calendar.getInstance();
c.setTime(sdf.parse(today));
c.add(Calendar.DATE, 7); // number of days to add
today = sdf.format(c.getTime()); // dt is now the new date
} catch (Exception e) {
e.printStackTrace();
}
return today;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
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.