on 01-02-2008 12:11 PM
Dear friends,
I have to put tomorrow's date skipping Sunday in the mapping for a date field.
Can anyone help me how to do this?
Kind regards,
Kamran
Hi Kamran
What I could understand is that you need to check if the day after the current date is a Sunday and, if so, get the date corresponding to the following monday, right?
You can do this by using CurrentDate function and implementing the logic through a udf, with one string input parameter. The input of such UDF is currentDate function. Here's what the code would look like:
PS: You need to import java.text.* and java.util.* for this udf.
Regards and happy new year!
int diaSemana = 0;
try{
DateFormat format = new SimpleDateFormat("yyyy/MM/dd");
Calendar calendar = Calendar.getInstance();
Date date = format.parse(a);
calendar.setTime(date);
diaSemana = calendar.get(Calendar.DAY_OF_WEEK); /weekday/
if (diaSemana == 7) {
calendar.add(Calendar.DATE, 2);
date = calendar.getTime();
return new SimpleDateFormat("MM/dd/yyyy").format(date);
}
else {
calendar.add(Calendar.DATE, 1);
date = calendar.getTime();
return new SimpleDateFormat("MM/dd/yyyy").format(date);
}
} catch (Exception e){ }
return "";
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kamran,
that should be possible without UDF. Please try the following:
1. Use a concat with the following input parameters:
1a)
- currentDate (Target Format EEE)
- the result should be the current weekday (e.g. Mi for Wednesday here in Germany, maybe you got other values for another system installation)
- after the currentDate do FixValues and create a mapping table for the next day (e.g. Mi --> Do). If you want to leave out the Sunday you'll have to use the correct expected day therefore, e.g. Sa --> Mo.
1b)
- currentDate (Target Format MMyyyy)
2. The result of the concat should be the next weekday in letters concatenated with month and year in digits. Now use the DateTrans function with the following parameters:
2a) Source Date: EEEMMyyyy
2b) Target Date: for example yyyyMMdd --> this should be the correct day
Best regards
Lars
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
try DateAfter -> Advance Properties -> set the first weekday to sunday. This may help you to acheive success.
Regards
Aashish Sinha
PS : reward points if helpful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kamran !
Use this UDF to get the tomorrow date based on the input skipping sunday :
imports: java.util.Calendar;java.text.SimpleDateFormat;java.text.DateFormat;
public String Tomorrow(String a,Container container){
String notifyDates = a;
Calendar calendar = Calendar.getInstance ( ) ;
DateFormat dateFormat = new SimpleDateFormat ( "yyyy-MM-dd" ) ;
int days=1;
try {
Date date = dateFormat.parse ( notifyDates ) ;
calendar.setTime ( date ) ;
int day = calendar.get( Calendar.DAY_OF_WEEK );
if (day==1) days++;
calendar.add ( Calendar.DATE, days ) ; //.MONTH o .YEAR...
return dateFormat.format ( calendar.getTime ( ) ) ;
} catch ( Exception e ) {
return "error";
}
Regards,
Matias
ps: please award points if helpful.
Edited by: Matias Denker on Jan 2, 2008 11:27 AM
Hi Kamran,
Try using the date after function of the date functions in graphical editor. Might help. I have never used it though.
Thanks and Regards,
Sanjeev.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.