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

Eight Stars

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_2_0@TRF1@TRF@manodwhb


Accepted Solutions
Sixteen Stars

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

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.

Thirteen Stars

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

@abhi90,check this also may be usefull.Untitled.pngtmapUntitled.pngjob

Manohar B
Thirteen Stars

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

@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.

Manohar B
Six Stars

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

hi you can also use this expression

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


All Replies
Eight Stars

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

START_DATE column is String in Source

Eight Stars

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

Can anyone with any help? @xdshi,

Eight Stars

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

Hi @manodwhb

Sixteen Stars

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

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.

Thirteen Stars

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

@abhi90,check this also may be usefull.Untitled.pngtmapUntitled.pngjob

Manohar B
Thirteen Stars

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

@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.

Manohar B
Sixteen Stars

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

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.

Six Stars

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

hi you can also use this expression

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

Eight Stars

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

Thanks to evryone. @manodwhb@rhall_2_0@kiraninaparty. All the solutions are right. Handled the issue after 4 hours. Smiley Happy .Don't know which one to accept now

Thirteen Stars

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

@abhi90,you can accept solution as many,since all are rightMan Happy

Manohar B