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

Announcements
Note: You may notice some temporary visual or styling issues in the Community. Our vendor is actively investigating.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

yesterday's date

Hello !
I'm using a variable nb_day which is equal to 0 for today, 1 for yesterday, 2 for the day before...
I'm creating files and I want the date to be in the file names, so that for today my file name would be :
"D:/talend/AAA_"+TalendDate.formatDate("yyyyMMdd",TalendDate.getCurrentDate())+".log"
How can I get yesterday's date and so on like I do for today and using my variable ?
(basically I'm trying to do "D:/talend/AAA_"+TalendDate.formatDate("yyyyMMdd",TalendDate.getCurrentDate() - nb_day)+".log" but this is not working)
Thanks for your help ! 0683p000009MACn.png
Labels (2)
16 Replies
Anonymous
Not applicable
Author

It's because you have to multiply your parameter by one instead of just add a minus sign in front of it :
-1 * context.nb_days should work 0683p000009MA9p.png
Regards,
Karine
Anonymous
Not applicable
Author

-1 * context.nb_days should work 0683p000009MA9p.png

Thanks for your answer ! Unfortunately it seems it doesn't work.
I'm still getting the NullPointerException.
Anonymous
Not applicable
Author

Hello Augustine
Set a default value to context.nb_days, maybe 1. 0683p000009MACn.png
Best regards
shong
Anonymous
Not applicable
Author

I'm using v3.0.4 and am not able to modify the TalendDate system routine. Are there any special things I need to do to be able to modify it? Thanks.
Anonymous
Not applicable
Author

Hello
I'm using v3.0.4 and am not able to modify the TalendDate system routine. Are there any special things I need to do to be able to modify it? Thanks.

I don't think it is a good idea to modify the system routine directly. If you want to enhance it ,you can create a new routine, copy the code and modify it.
Best regards
shong
Anonymous
Not applicable
Author

String logFileName = "D:/talend/AAA_" + TalendDate.formatDate("yyyyMMdd", TalendDate.addDate(TalendDate.getCurrentDate(), - nb_day, "dd")) + ".log";
Tasfiahm
Creator
Creator

Thanks a lot. I did something similar. 

 

"F:/Talend/Work" + TalendDate.formatDate("MMddyyyy",TalendDate.addDate(TalendDate.getCurrentDate(), - 10, "dd"))+".csv"