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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Get date of the monday week - 3

Hello,
I would like to get date of the monday week -3 with "talend code"
Exemple : we are on 2015-10-20. I would like to show these date : 2015-09-28 and 2015-10-19
the first date is monday of week -3 and the second date is monday of current week.
sorry for my poor english
thx

Labels (2)
1 Reply
Anonymous
Not applicable
Author

Hi 
Create a routine in Repository and hard code to calculate the current Monday of each date, eg:
package routines;
import java.util.Date;

public class MyRoutine {

static int day_of_week;
static Date currentMonday;

public static Date getCurrentMonday(Date date) {
day_of_week=TalendDate.getPartOfDate("DAY_OF_WEEK", date);
if(day_of_week==1){
currentMonday= TalendDate.addDate(date, 1, "dd");
}else if(day_of_week==2){
currentMonday=date;
}else if(day_of_week==3){
currentMonday= TalendDate.addDate(date, -1, "dd");
}else if(day_of_week==4){
currentMonday= TalendDate.addDate(date, -2, "dd");
}else if(day_of_week==5){
currentMonday= TalendDate.addDate(date, -3, "dd");
}else if(day_of_week==6){
currentMonday= TalendDate.addDate(date, -4, "dd");
}else {
currentMonday= TalendDate.addDate(date, -5, "dd");
}

return currentMonday;
}
}


Then, call this routine in the job, see details:
0683p000009MGpG.png 0683p000009MGpL.png 0683p000009MGpQ.png
Best regards
Shong