
Contributor
2014-12-08
05:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[resolved] cannot convert string to date in tMap
Hi everyone.
I've the csv file in which one column has date (which is defined as Number in csv file) but in tFileInpuDelimited it read as string in which some of the vales are like 20140424 and some are like 2014-04-25 in the same column.I've to parse this data into output component( tOracleOutput)as date column.So I tried to convert the string to date by using
TalendDate.parseDate("yyyy-MM-dd",TalendDate.formatDate("yyyy-MM-dd",row1.column1)) and changed the output column as date with format yyyy-MM-dd.
Then I'm getting error as
Unparseable date: "20140424".
How could I parse this into output component?
Any help would be greatly appreciated.
Thank you in advance.
I've the csv file in which one column has date (which is defined as Number in csv file) but in tFileInpuDelimited it read as string in which some of the vales are like 20140424 and some are like 2014-04-25 in the same column.I've to parse this data into output component( tOracleOutput)as date column.So I tried to convert the string to date by using
TalendDate.parseDate("yyyy-MM-dd",TalendDate.formatDate("yyyy-MM-dd",row1.column1)) and changed the output column as date with format yyyy-MM-dd.
Then I'm getting error as
Unparseable date: "20140424".
How could I parse this into output component?
Any help would be greatly appreciated.
Thank you in advance.
2,221 Views
- « Previous Replies
- Next Replies »
1 Solution
Accepted Solutions

Anonymous
Not applicable
2015-11-19
04:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Shri_Kul1,
Please take a look at my screenshot.
Feel free to let us know if it is what you are looking for.
Best regards
Sabrina
Please take a look at my screenshot.
Feel free to let us know if it is what you are looking for.
Best regards
Sabrina
1,602 Views
32 Replies

Anonymous
Not applicable
2014-12-08
05:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
use below code.
TalendDate.parseDate("yyyyMMdd",row1.column1)
1,102 Views

Contributor
2014-12-08
05:53 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your prompt reply umesh.
I tried even that also. But it didn't works. Would you suggest more ideas?
Can I write if else condition in tMap to take any value either yyyyMMdd format or yyyy-MM-dd format and then to insert into output column as date with yyyy-MM-dd format? If so How should I implement this?
Any help would be appreciated.
Thank you.
I tried even that also. But it didn't works. Would you suggest more ideas?
Can I write if else condition in tMap to take any value either yyyyMMdd format or yyyy-MM-dd format and then to insert into output column as date with yyyy-MM-dd format? If so How should I implement this?
Any help would be appreciated.
Thank you.
1,102 Views

Anonymous
Not applicable
2014-12-08
06:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
output will not ask you for specific format, it will required only Date object, If you show me input string from your file then I can suggest you better.
1,102 Views

Contributor
2014-12-08
06:19 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your reply. The input column is as below.
Date
2014-12-21
20140214
2014-12-13
2014-12-23
20141201
The output should be in yyyy-MM-dd fromat only whatever may be the input format.
Date
2014-12-21
20140214
2014-12-13
2014-12-23
20141201
The output should be in yyyy-MM-dd fromat only whatever may be the input format.
1,102 Views

Anonymous
Not applicable
2014-12-08
07:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So you have two formats in single column. then you can use below logic which help you.
this will solve your problem.
yourcolumn!=null && yourcolumn!=" "?
TalendDate.parseDate("yyyyMMdd', yourcolumn.replaceAll("-", "")):null
this will solve your problem.
1,102 Views

Contributor
2014-12-08
07:31 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your prompt reply.
Sorry Umesh I forgor to tell you onemore thing.
I also had -1,-2 values in that same column.That above problem is solved with TalendDate.parseDate("yyyyMMdd",row1.Column1).
Now the problem is with -1,-2 values. I've to place 0000-00-00 in output column when I get those values from input file.
How could I do this?
Thanks you
Sorry Umesh I forgor to tell you onemore thing.
I also had -1,-2 values in that same column.That above problem is solved with TalendDate.parseDate("yyyyMMdd",row1.Column1).
Now the problem is with -1,-2 values. I've to place 0000-00-00 in output column when I get those values from input file.
How could I do this?
Thanks you
1,102 Views

Anonymous
Not applicable
2014-12-08
08:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can do in the same way, you have to check the length of column if it is less than expected then replace with, desire string.
1,102 Views

Contributor
2014-12-08
11:17 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your reply Umesh. But I didn't get you. Where to check the length of column?
1,102 Views

Anonymous
Not applicable
2014-12-09
02:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
check the length of the column in same code.
yourcolumn!=null && yourcolumn!=" " && yourcolumn.length>68?
TalendDate.parseDate("yyyyMMdd', yourcolumn.replaceAll("-", "")):TalendDate.parseDate("yyyyMMdd', "000000")
1,102 Views

- « Previous Replies
- Next Replies »