Parse date from globalMap

Highlighted
Seven Stars

Parse date from globalMap

Hi!
I am using a sql query with parameters. I am getting those parameters with the component tMsgBox as a globalvar. 
This is a part from the query with mssqlinput:
par.data > TalendDate.formatDate("dd-MM-yyyy", (String)globalMap.get("tMsgBox_2_RESULT"))  and par.data < '30-11-2015' and cli.razon like '"+(String)globalMap.get("tMsgBox_1_RESULT")+"%'

On the blue code, I can compare the parameter from the tmsgbox without problem because it's a string, but when I want to input a date with the format "dd-mm-yyyy" talend is giving me an error all the time. I just want to convert that string to a date, in order to compare this on the sql.
Highlighted
One Star

Re: Parse date from globalMap

Hi,
Think of SQL query as a String. So, you don't have to convert tMsgBox_2_Result to a Date, just compose the String as if you've type it by yourself:
"par.data > '" + (String)globalMap.get("tMsgBox_2_RESULT") + 
"' and par.data < '30-11-2015' and cli.razon like '" +
(String)globalMap.get("tMsgBox_2_RESULT") + "%'"

Hope this helps,
TRF
Highlighted
Seven Stars

Re: Parse date from globalMap

Helps a lot. Thank you.

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog