Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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.
START_DATE column is String in Source
Can anyone with any help? @xdshi,
Hi @manodwhb
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.
@abhi90,check this also may be usefull.tmap
job
@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.
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.
hi you can also use this expression
TalendDate.parseDateLocale("dd-MMM-yy",row2.date,"EN")