BIGINT - STRING DATE FORMAT

One Star

BIGINT - STRING DATE FORMAT

one of the column in my MySQL db table is
"job_UTC_Time"  "BIGIINT" datatype - length 20
UTC_Time is in milliseconds.  for example: 1451427036333

By using the tMySQLInput, I need to qurey all the columns includting job_UTC_time.

The query should also include the where condition.
where job_UTC_Time >= context.start_date and job_UTC_Time <= context.enddate

context variables are defined as string and default vale is set as '2015-01-01 00:00:00' (start_date) and '2016-03-09 00:00:00' (enddate)

How can I compare BIGINT which hold data in milliseconds with start_date which is string?
I could not attach screenshots as this forum throws errors :The server was unable to save the uploaded file.

Community Manager

Re: BIGINT - STRING DATE FORMAT

Hi 
Convert the string value to a Date, and get the millseconds using the method getTime(), try this:
"....where job_UTC_Time>="+(TalendDate.parseDate("yyyy-MM-dd HH:mm:ss",context.[color=#5b5b5d][font=Verdana, Helvetica, Arial, sans-serif]start_date)).getTime()+" and job_UTC_Time <="+[/font][/color](TalendDate.parseDate("yyyy-MM-dd HH:mm:ss",context.enddate)).getTime()

Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

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 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

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog