Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
stagliaferri1640766615
Contributor II
Contributor II

setting a variable if today = first Saturday of the month

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

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable

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

 

View solution in original post

3 Replies
Anonymous
Not applicable

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

 

stagliaferri1640766615
Contributor II
Contributor II
Author

thank you very much!

very smart solution!

thank you very much !

Anonymous
Not applicable

I'm glad it helps you!