Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Query in tmssqlInput to retrieve data on date conditon

Hi,
I have requirement where i have to query data on the table based on the date condition and write it into a csv file.
I have used the where conditon in query like :
"where modification_time<'Talend.getCurrentDate()-30'"
but this is giving me an error 
"Conversion failed when converting the varchar value 'TalendDate.getCurrentDate()' to data type int."

please help as this is urgent.
Thanks,
Tulasi
Labels (3)
10 Replies
Jcs19
Creator II
Creator II

HI,
We are actually trying to archive the data from database of past 120 days from today and write it into a csv file.
I am querying on a table using the tmssqlInput--->tmap--->tfileoutputdelimited.
In tmssqlInput i am writing a select query based on the condition:
select * from table where modified_date < today's date-120
where modified_date is column in the table and today's date is currentdate.
Now i am not able to use the '<' condition properly.

< and > should work on your sql query
I'm pretty sure that you made a mistake on today's date-120
At the end, your SQL Query should be like "select * from table where modified_date < '2015-05-02';"

I wanted you to find the solution alone, it's so much more exciting

Two solutions 
SQL: "Select * from table WHERE modified_date > DATEADD( dd, -120, getdate()) ;"

Java: "Select * from table where modified_date < ' " +  TalendDate.formatDate("yyyy-MM-dd",TalendDate.addDate(TalendDate.getCurrentDate(),-120,"dd")) + " ' ;"