Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello community,
I would need your help.
I would like to assign a value to my variable x (using tjava) as per the following:
if today is first saturday of the month --> 30 else 3
but I am able only to retrieve if today is saturday:
int x = 3;
int currentDay = TalendDate.getPartOfDate("DAY_OF_WEEK",TalendDate.getCurrentDate());
if(((int)currentDay == 7))
{
x = 30;
};
Date currentDate = TalendDate.addDate(TalendDate.getCurrentDate(),- x,"dd");
How could I implement it?
thanks
sergio
try this:
int x=3;
java.util.Date currentDate=TalendDate.getCurrentDate();
int dayOfWeek=TalendDate.getPartOfDate("DAY_OF_WEEK", currentDate);
int dayOfMonth=TalendDate.getPartOfDate("DAY_OF_MONTH", currentDate);
//System.out.println(dayOfWeek);
//System.out.println(dayOfMonth);
if(dayOfWeek==7&&dayOfMonth<8){
x=30
}
Regards
Shong
try this:
int x=3;
java.util.Date currentDate=TalendDate.getCurrentDate();
int dayOfWeek=TalendDate.getPartOfDate("DAY_OF_WEEK", currentDate);
int dayOfMonth=TalendDate.getPartOfDate("DAY_OF_MONTH", currentDate);
//System.out.println(dayOfWeek);
//System.out.println(dayOfMonth);
if(dayOfWeek==7&&dayOfMonth<8){
x=30
}
Regards
Shong
thank you very much!
very smart solution!
thank you very much !
I'm glad it helps you!