
Specialist III
2015-08-21
04:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to use TalendDate.parseDate() to convert from string to date
Hi,
I have a date(String data type) column in mysql table , values are in 2 formates 'yyyyMMdd_hhmmssSSS' and 'yyyy-MM-dd hh:mm:ss'.
I can convert this string type to date using TalendDate.parseDate("yyyyMMdd_hhmmssSSS",row1.date);
this conversion i am using inside a tMap component. My question is How to use TalendDate.parseDate() for both the date formates at once?
Right now I am getting unparsable date formate error since I am not handling this 'yyyy-MM-dd hh:mm:ss' format. Please help.
Thanks
I have a date(String data type) column in mysql table , values are in 2 formates 'yyyyMMdd_hhmmssSSS' and 'yyyy-MM-dd hh:mm:ss'.
I can convert this string type to date using TalendDate.parseDate("yyyyMMdd_hhmmssSSS",row1.date);
this conversion i am using inside a tMap component. My question is How to use TalendDate.parseDate() for both the date formates at once?
Right now I am getting unparsable date formate error since I am not handling this 'yyyy-MM-dd hh:mm:ss' format. Please help.
Thanks
2,108 Views
4 Replies

Anonymous
Not applicable
2015-08-21
05:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If understood correctly you have a column called row1.date which has two different type of dates, in single column?
then you can do it in following way.
Try this one or you can check more date formats on talend-date-routine-function-with-examples
then you can do it in following way.
row1.date.contains("_")? TalendDate.parseDate("yyyyMMdd_hhmmssSSS",row1.date): row1.date.contains(":")? TalendDate.parseDate("yyyy-MM-dd hh:mm:ss",row1.date):TalendDate.getDate()
Try this one or you can check more date formats on talend-date-routine-function-with-examples
2,108 Views

Specialist III
2015-08-21
06:38 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank You. I will try this.
2,108 Views

Specialist III
2015-08-24
02:31 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much. Problem resolved. This worked perfectly.
2,108 Views

Anonymous
Not applicable
2015-08-24
03:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Happy to see it works.. you can now closed this topic, mark it Resolve.
2,108 Views
