Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
abhi90
Creator II

Parse to MM/dd/yyyy format Date from dd-Mon-yy Format and Validation

Hi All,

 

I have a scenario. My Source Data Date is coming in dd-Mon-yy. Example 9-Jun-17. I want to convert it into MM/dd/yyyy. Final Desired Output will be 6/9/2017. Using TalendDate.parseDate("MM/dd/yyyy",row1.START_DATE). But getting Unparseable Date error. Also want to create a Variable Port where it will check for format..In the Variable Port Condition is like this

TalendDate.isDate(row1.START_DATE,"dd-MMM-yy",true). But it is also not working. Can anyone please help

@vboppudi@rhall@TRF@TRF@manodwhb

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

You need to do it like this.....

 

routines.TalendDate.formatDate("d/M/yyyy", routines.TalendDate.parseDate("dd-MMM-yy", row.datacolumn))

....for 6/9/2017, or like this.....

routines.TalendDate.formatDate("dd/MM/yyyy", routines.TalendDate.parseDate("dd-MMM-yy", row.datacolumn))

....for 06/09/2017.

View solution in original post

10 Replies
abhi90
Creator II
Author

START_DATE column is String in Source

abhi90
Creator II
Author

Can anyone with any help? @xdshi,

abhi90
Creator II
Author

Hi @manodwhb

Anonymous
Not applicable

You need to do it like this.....

 

routines.TalendDate.formatDate("d/M/yyyy", routines.TalendDate.parseDate("dd-MMM-yy", row.datacolumn))

....for 6/9/2017, or like this.....

routines.TalendDate.formatDate("dd/MM/yyyy", routines.TalendDate.parseDate("dd-MMM-yy", row.datacolumn))

....for 06/09/2017.

manodwhb
Champion II

@abhi90,check this also may be usefull.0683p000009Lw89.pngtmap0683p000009Lx34.pngjob

manodwhb
Champion II

@abhi90,to check the date is valid or not in variable port you should use TalendDate.isDate(row2.Date,"d-MMM-yy",true) as per your input date format.

Anonymous
Not applicable

It should be made clear that a Date is a number. It does not come with a format, but it can be formatted for when it is output as a String. The example I gave takes a date delivered in a String format, converts it to a Date (just a number) and then converts it back to a String. When Talend outputs a Date in a tLogRow it implicitly converts it to a String (the same with numbers). However, a component receiving a Date from a tLogRow will just receive a number.

Anonymous
Not applicable

hi you can also use this expression

TalendDate.parseDateLocale("dd-MMM-yy",row2.date,"EN")

abhi90
Creator II
Author

Thanks to evryone. @manodwhb@rhall@nannan. All the solutions are right. Handled the issue after 4 hours. 0683p000009MACn.png .Don't know which one to accept now