• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » tMSSqlInput query command to filter records by dates problem

#1 2011-09-09 15:56:53

twitkmg
New member
Registered: 2011-08-17
Posts: 5

tMSSqlInput query command to filter records by dates problem

Hi,

I am reading an input file from SQL database which required date filtering using Talend global context date variables.
The SQL date format is different from the global context variable defined. I am not allowed the define these date fields format in SQL and Talend.

The fields & format :

dbo.gl_entry.input_dt  format is "dd/MM/yyyy HH:mm:ss AM",
context.DATE_START format is "dd-MM-yyyy", and
context.DATE_END format is "dd-MM-yyyy".


The extract of the query command in tMSSQLInput_1 syntax:

"SELECT dbo.gl_entry.input_dt,
            dbo.gl_entry.amount,
        dbo.gl_entry.ccy,
        dbo.gl_entry.deal_no,
        dbo.gl_entry.trans_type
FROM    dbo.gl_entry
WHERE
dbo.gl_entry.input_dt >= '"+TalendDate.formatDate("MM/dd/yyyy HH:mm:ss",context.DATE_START)+"' and
dbo.gl_entry.input_dt <= '"+TalendDate.formatDate("MM/dd/yyyy HH:mm:ss",context.DATE_END)+"'"


Basically, there is no syntax error. However, I am not getting the expected output wanted due to different format in dates.
(Note: the SQL date has the AM/PM format).

Glad if someone can help solve this.

Thank you and regards
KM

Last edited by twitkmg (2011-09-09 16:30:50)

Offline

#2 2011-09-09 18:06:24

jandry
Talend team
Registered: 2008-05-14
Posts: 405

Re: tMSSqlInput query command to filter records by dates problem

I believe the problem is in your format "MM/dd/yyyy HH:mm:ss" MySQL will only recognize a form of "yyyy/MM/dd HH:mm:ss"

http://dev.mysql.com/doc/refman/5.5/en/datetime.html

Offline

#3 2011-09-12 05:10:49

twitkmg
New member
Registered: 2011-08-17
Posts: 5

Re: tMSSqlInput query command to filter records by dates problem

Hello jandry.,

I've tried using format "yyyy/MM/dd HH:mm:ss" on  query SQL table, it doesn't work, perhaps it's for MySQL only.
Any other suggestion?

Thanks & regards,
Km

Last edited by twitkmg (2011-09-12 05:11:49)

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » tMSSqlInput query command to filter records by dates problem

Board footer

Powered by FluxBB