Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
JABELLA1634831127
Contributor III
Contributor III

Is it possible to create a timestamp in tmap output that iterates per 5 minutes?

So currently I have a date that I ingested from a filename and it has a format of "dd-MM-yyyy HH:mm" and the HH:mm is currently 00:00. Is it possible that it iterates per 5 minutes 00:00, 00:05 up to 23:55?

0695b00000L0ZpmAAF.png

Labels (2)
11 Replies
Anonymous
Not applicable

This will do it....

 

public class DateIteration {

 

 

private static Date date;

private static int initialDay;

 

public static Date iterateDates(Date sourceDate, int minutesToAdd) {

 

if(date==null) {

 

date = sourceDate;

initialDay = routines.TalendDate.getPartOfDate("DAY_OF_WEEK", sourceDate);

}else{ //New section

if(initialDay!=routines.TalendDate.getPartOfDate("DAY_OF_WEEK", date)){

date = routines.TalendDate.addDate(date,-1,"dd");

 

}

}

 

date = routines.TalendDate.addDate(date, 5, "mm");

 

/* Code moved to the "else" of the first if condition

if(initialDay!=routines.TalendDate.getPartOfDate("DAY_OF_WEEK", date)){

date = routines.TalendDate.addDate(date,-1,"dd");

 

} */

 

return date;

}

 

}

 

I simply moved the if condition which deals with the amendment of the day in the date to the "else" of the first if condition. What this does is leave the very first time the day ticks over to the next day. Then the next time the method is called it checks the original day against the current value's day. When they do not match, it automatically removes a day.

 

You will need to ensure that all dates supplied have 00:00:00.000 as the time. If not, you will need to add something to this to ensure that the time is changed to 00:00:00.000.

JABELLA1634831127
Contributor III
Contributor III
Author

Thanks again for all your help and apologies for asking so much questions. It works now and yup the dates will have 00:00:00 as the time.