Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

File name with a timestamp

I have one question.
I want to give my file's name with a time stamp
It will be like "filename_yyyyMMdd_HHmm.dat"
But I have to find this file again in the job so, I want to store the "yyyyMMdd_HHmm" value in a context or variable.
and assign that context or variable to the file name.
Can you direct me how it can be done???
I've tried making a context of type string whose value is TalendDate.formatDate("yyyyMMdd_HHmm",TalendDate.getCurrentDate())
But when i run it i got a file not found exception (I'm to create a file not find for the first time).
and I think the context returns as a string of "TalendDate.formatDate("yyyyMMdd_HHmm",TalendDate.getCurrentDate())" not the actural date time value.
Thank You.
 
 
Labels (3)
1 Reply
TRF
Champion II
Champion II

Using tSetGlobalVar when the job starts, define a global variable to store the current timestamp then reuse it anywhere in your job (because "mm" changes every 60 secondes):
0683p000009M7Wd.png
In this example, the timestamp global variable is reused in the same tSetGlobalVar to construct the logfile variable (which contains a log filename) but you can reuse anywhere you want such as in tFileXxxxx components.