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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
hgromek
Contributor
Contributor

Talend Job, Runs with CURDATE() Doesn't get current date when ran with Windows Task Schedule

HI, I have a Job that runs and grabs the last 7 days of data - emails it to me. When ran in TOS it is corrected. When I create the Bat file and run with Windows Task Scheduler it uses the last day it was ran in Talend as the Current Date and not the actual date ran. 

 

Any suggestions on how to get the CURDATE  in the mysql import query to use the actual date the task schedule is running?

 

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

I don't see why CurDate in mySQL would be affected by this. Maybe you could show us your code? But this solution will work for you. In a tJava at the beginning of your job, place this code....

globalMap.put("Date", routines.TalendDate.formatDate("yyyy-MM-dd", routines.TalendDate.getCurrentDate()));

This will store a correctly formatted (for mySQL) Date as String in the globalMap. Then in your MySQL query you can use it in the Where Clause like this....

"Select
Your,
Column,
Data
From Your.Table
Where yourDateColumn < '" +((String)globalMap.get("Date"))+"'"

View solution in original post

4 Replies
Anonymous
Not applicable

Hello,

Does your job work perfectly fine when you run your job script .bat file directly in cmd without using Windows Task Scheduler ?

Best regards

Sabrina

hgromek
Contributor
Contributor
Author

cmd does use the actual curdate - so it works through there! How do I get that to run a scheduled basis? 

Anonymous
Not applicable

I don't see why CurDate in mySQL would be affected by this. Maybe you could show us your code? But this solution will work for you. In a tJava at the beginning of your job, place this code....

globalMap.put("Date", routines.TalendDate.formatDate("yyyy-MM-dd", routines.TalendDate.getCurrentDate()));

This will store a correctly formatted (for mySQL) Date as String in the globalMap. Then in your MySQL query you can use it in the Where Clause like this....

"Select
Your,
Column,
Data
From Your.Table
Where yourDateColumn < '" +((String)globalMap.get("Date"))+"'"
hgromek
Contributor
Contributor
Author

My code used CURDATE directly in the sql. By doing the Java date, we are able to fins a solution that works! thank you for your assistance!