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: 
Amit4
Contributor III
Contributor III

Load date time in context variable

How to store the Date and Time values in context variable and write into a csv file.

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable

You can get the current Date and Time using built-in function TalendDate.getCurrentDate(), eg:

 

on a tJava:

context.currentDate=TalendDate.getCurrentDate();

context.stringDatePart=TalendDate.formatDate("yyyy-MM-dd",context.currentDate);

context.stringTimePart=TalendDate.formatDate("HH:mm:ss",context.currentDate);

 

System.out.println(context.currentDate);

System.out.println("the date part is: "+context.stringDatePart);

System.out.println("the time part is: "+context.stringTimePart);

 

 

0695b00000bEc4CAAS.png 

Get the current Date and Time, store them into context variables, use these context variables later on other components.

If you need to output the Date and Time to CSV, just use a tfixedFlowInput to generate the data flow.

0695b00000bEc4gAAC.png 

Hope it helps you!

 

Regards

Shong

View solution in original post

4 Replies
Anonymous
Not applicable

Hi

Do you want to get the current Date and Time? Can you show an example what data you want? So we can give your more precise answer?

 

Regards

Shong

Amit4
Contributor III
Contributor III
Author

Hi Shong,

 

As I mentioned that I want to create a job which can write the current Date and Time in csv file i.e, whenever I run the job current time should be stored in my csv file. But the problem is I am not able to do using context variable. Hope it is clear now.

 

Thank and Regards

Amit Yadav

Anonymous
Not applicable

You can get the current Date and Time using built-in function TalendDate.getCurrentDate(), eg:

 

on a tJava:

context.currentDate=TalendDate.getCurrentDate();

context.stringDatePart=TalendDate.formatDate("yyyy-MM-dd",context.currentDate);

context.stringTimePart=TalendDate.formatDate("HH:mm:ss",context.currentDate);

 

System.out.println(context.currentDate);

System.out.println("the date part is: "+context.stringDatePart);

System.out.println("the time part is: "+context.stringTimePart);

 

 

0695b00000bEc4CAAS.png 

Get the current Date and Time, store them into context variables, use these context variables later on other components.

If you need to output the Date and Time to CSV, just use a tfixedFlowInput to generate the data flow.

0695b00000bEc4gAAC.png 

Hope it helps you!

 

Regards

Shong

Amit4
Contributor III
Contributor III
Author

Thanks Shong,

It worked for me.