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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

create a calendar table

Hello,
I will try to explain myself, I'm a newbie with TOS DI and I'm trying to create a table wich will provide me a calendar for future maintenance events.
I have a table which contain future maintenance activities (maint) with the next execution date (nextdate) and a frequency (freq) and unit frequency (frequnit)
for example
MAINT    |  NEXTDATE  | FRQ | FREQUNIT |
MAINT1  |  01/06/2015 |  1    | MONTH    |
The result should be a list of all maintenance date for n months (for example 12M)
ID  | MAINT    |  CALCNEXTDATE 
1   | MAINT1  |  01/06/2015
2   | MAINT1  |  01/07/2015
3   | MAINT1  |  01/08/2015
4   | MAINT1  |  01/09/2015
5   | MAINT1  |  01/10/2015
6   | MAINT1  |  01/11/2015
etc...
What should I use for having this output.
In advance thanks,
Labels (2)
5 Replies
Anonymous
Not applicable
Author

Hi lhamlein,
Interesting scenario. 0683p000009MACn.png
This is what I've come up with:
1. We'll need to have 2 flows, one from the source file reading the above mentioned record; & the second from a tFixedFlowInput component where we'll create the no of iterations we need (n, as per your above post)
2. These 2 flows would merge in a tMap, as shown below:
0683p000009MCO7.png
where 'nxt_date' column gets its value as:
TalendDate.addDate(row2.nxt_date,"dd/MM/yyyy",row4.repeatations,"MM")


0683p000009MCUd.png
output:
0683p000009MCUi.png
Hope this helps. 0683p000009MACn.png
MathurM
Anonymous
Not applicable
Author

It works but I have used TalendDate.addDate(row3.NEXTDATE,row4.repeatations*row3.FREQUENCY ,"MM")   .
as my fields are dates
thanks,
Anonymous
Not applicable
Author

hello,
my problem now is that I have 3 types of frequency unit weeks, month, year.
So if repeating 52 times for the weeks is ok and give me all occurence between now and now+52weeks.
For a frequency "year" it repeats it for the next 52 years, which create to many occurence for what I need.
Is there a way to have 3 different calculation based on the frequency unit.
My iterator will be in Year.
Case frequency= 'weeks' then TalendDate.addDate(NextDate.NEXTDATE,iterator.iterator*365*NextDate.FREQWKS,"dd")
Case frequency ='month' then TalendDate.addDate(NextDate.NEXTDATE,iterator.iterator*12*NextDate.FREQUENCY,"MM")
Case frequency ='year' then TalendDate.addDate(NextDate.NEXTDATE,iterator.iterator*NextDate.FREQUENCY,"yyyy")
Thanks,
Anonymous
Not applicable
Author

Hello, I'm a beginner on Talend.
I have a little the same problem, but I did not manage to adapt your answers to my situation.

I was wondering if it was possible to create a new variable that displays all the dates for the current month.
Let me explain. I would like, starting from nothing, to create a new variable on talend which takes into account the day that it is at the time of its execution.
And that displays every day of the month. (Which takes into account the months of 30 or 31 days as well as the month of February).
I succeeded using the tjava tool to create an ArrayList which contains the values ​​I want to obtain. But however, I don't see how I can use it afterwards. Because I would like to have a variable that I can then use in a tmap or each line corresponds to a different day.

I do not know if I am very clear. Do not hesitate to ask questions if this is not the case.
Thank you for your answers.

Sorry for my English
raoh
Contributor
Contributor

Hello,

 

I created a calendar table by following this tutorial:

 

bekwam's tutorial

 

It's an old post, but still usefull (at least for me)

 

In your tJavaRow You can manipulate the dates to your liking, for example :

 

output_row.dayOfYear = new Integer(cal.get(Calendar.DAY_OF_YEAR));
output_row.isFirstDayOfMonth = new Integer(1).equals(output_row.day);
output_row.isLastDayOfMonth = output_row.day.equals(cal.getActualMaximum(Calendar.DATE));
output_row.numWeek = cal.get(Calendar.WEEK_OF_YEAR);

See if you can combine this with the solution provided by @mathurm .

 

If you find the solution, it would be nice to come and share it with us, it could help other people...

 

Regards,

 

PS : i found another tutorial for calendar :diethardsteiner's tutorial