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: 
Anonymous
Not applicable

File name with a timestamp

Hi,
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 (2)
18 Replies
Anonymous
Not applicable
Author

@Puspanjali12 

 

   Could you please let us know the exact format you are looking?

 

   Then we can suggest the corresponding format to you.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

 

Anonymous
Not applicable
Author

@nthampi 

 

I want to append the current date in a filename and the date should be in CST timezone.
for ex: data02212019051444

 

Regards,

Puspanjali

Anonymous
Not applicable
Author

@Puspanjali12 

 

Please refer the below diagram.

0683p000009M3Ga.png

 

 

I have used the java libraray joda-time and the screen shots for tlibraryload are as below.

0683p000009M3Hr.png

 

0683p000009M3Hw.png

 

 import org.joda.time.DateTime;
 import org.joda.time.DateTimeZone;
 import org.joda.time.format.DateTimeFormatter;
 import org.joda.time.format.DateTimeFormat;

tMap screenshot is as below.

0683p000009M3I1.png

 

row1.input+DateTime.now(DateTimeZone.forID( "America/Chicago" ) ).toString(DateTimeFormat.forPattern("MMddyyyyHHmmss"))

And you got the answer 🙂

 

Please spare a second to mark the topic as resolved. Kudos are also welcome 🙂

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

 

 

Anonymous
Not applicable
Author

@nthampi 

 

Thanks. It's working!!

Anonymous
Not applicable
Author

The best for me
Anonymous
Not applicable
Author

excelent...!

 

 

 


filename with datestamp.png
SJeshwani1618330394
Contributor
Contributor

Hey hi @pariyarath Kiran​ ,

 

Your solution is working perfectly when we give it in a file path, but I want to use context variable and while I am giving this path in a context variable, it's not working.

 

do you have any idea about this?

Thank you

 

Regards,

Sheetal

1636848613
Contributor III
Contributor III

"D:/filedirectory/fileout_"+TalendDate.formatDate("yyyyMMdd_HHmm",TalendDate.getCurrentDate())+".csv"

 

Seems to work when writing a file, but not on tFileCopy??

1636848613
Contributor III
Contributor III

Diregard... needed spaces around + 😂