Date Parsing...

Six Stars

Date Parsing...

Hi 

I'm having real trouble converting an input string of

 

2010-01-26T00:00:00

 

to a date string YYYY-MM-DD

 

The issue in my dateParse is the T - can't work out the for life of me how to set the input format in the parsing to convert to what I need.

 

Any help would be great.

 

Thanks

Dave


Accepted Solutions
Nine Stars

Re: Date Parsing...

Hi @DaveG2008 ,

you can convert string to date by using talenddate.parsedate method and if you want the vice - versa (Date to string) - then use talenddate.formatdate method.

Pls check the below screen shots -

datetime-result.PNGresulttmap-result.PNGtmaprow-generator.PNGrow generator and date as string value

---> TalendDate.parseDate("yyyy-MM-dd",row1.Date) <------

Pls get back to Community, if necessary.

Thanks,

Ankit.

View solution in original post


All Replies
Seven Stars

Re: Date Parsing...

Hi Dave,

 

I think this should work:

your_date = TalendDate.parseDate("yyyy-MM-dd'T'HH:mm:ss", your_input_string)
your_output_string = TalendDate.formatDate("yyyy-MM-dd", your_date) 

 

Best regards,

 

Thomas

Tags (1)
Six Stars

Re: Date Parsing...

that worked - thanks.  I was going round in circles...

Nine Stars

Re: Date Parsing...

Hi @DaveG2008 ,

you can convert string to date by using talenddate.parsedate method and if you want the vice - versa (Date to string) - then use talenddate.formatdate method.

Pls check the below screen shots -

datetime-result.PNGresulttmap-result.PNGtmaprow-generator.PNGrow generator and date as string value

---> TalendDate.parseDate("yyyy-MM-dd",row1.Date) <------

Pls get back to Community, if necessary.

Thanks,

Ankit.

View solution in original post

Six Stars

Re: Date Parsing...

Should have replied earlier.  This worked perfectly - thanks for the help.

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