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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Export File with offset week number as filename

I have a relatively simple task which I can't seem to get my head around.

 

I've created a job which queries a database and outputs the results in an excel file for end users to utilise. 

 

 

The file has data pertaining to business transacted by the company in the previous week and I need to output the file with previous week number. I currently can get the file to output with the current week number using the Filename field in tFileOutputExcel Component as follows:

"$$PATH\\FILENAME WEEK "+TalendDate.getPartOfDate("WEEK_OF_YEAR", TalendDate.parseDate("dd-MM-yyyy", TalendDate.getDate("dd-MM-YYYY")))+"xlsx"

 

This outputs "FILENAME WEEK 38" but I need it to be offset by -1 week, so it is named "FILENAME WEEK 37 and I can't figure out how to get this to work as it doesn't seem to follow the same logic as the daily one:

 

+TalendDate.addDate(TalendDate.getDate("yyyyMMdd"),"yyyyMMdd",-1,"dd") - This will produce an offset of 1 day

 

Any insight would be greatly appreciated.

 

I'm using version 6.4.1

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

This was my initial approach, but I realize now where I was going wrong - I needed to include the date adjustment as a nested TalendDate.getDate function within the parseDate function 

 

This works:

 

"$$PATH/FILENAME WEEK "+TalendDate.getPartOfDate("WEEK_OF_YEAR", TalendDate.parseDate("dd-MM-yyyy", TalendDate.getDate(TalendDate.addDate(TalendDate.getDate("dd-MM-yyyy"),"dd-MM-yyyy",-7,"dd")))) +".xlsx"

View solution in original post

3 Replies
Anonymous
Not applicable
Author

Have you tried subtracting 7 days from the current date?

fdenis
Master
Master

TalendDate.addDate(TalendDate.getDate("yyyyMMdd"),"yyyyMMdd",-7,"dd")

week is 7 days

Anonymous
Not applicable
Author

This was my initial approach, but I realize now where I was going wrong - I needed to include the date adjustment as a nested TalendDate.getDate function within the parseDate function 

 

This works:

 

"$$PATH/FILENAME WEEK "+TalendDate.getPartOfDate("WEEK_OF_YEAR", TalendDate.parseDate("dd-MM-yyyy", TalendDate.getDate(TalendDate.addDate(TalendDate.getDate("dd-MM-yyyy"),"dd-MM-yyyy",-7,"dd")))) +".xlsx"