Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
profuse
Creator
Creator

How do I convert string format dd-MMM-yy to date format mm/dd/yy?

Can someone tell me how to convert tFileInputDelimited input string field formatted as dd-MMM-yy

to an output date field formatted as like mm/dd/yy using tMap?

 

Thank you.

Labels (2)
1 Solution

Accepted Solutions
tnewbie
Creator II
Creator II

TalendDate.isDate(incoming_row.incoming_col_value,"dd-MMM-yy") ? TalendDate.parseDate("dd-MMM-yy",incoming_row.incoming_col_value) : null and in the Date Pattern put the date format "mm/dd/yy" please see the attachment

 

Notes:

1) Your incoming value should be a string data type

2) your output port should be date data type


date_formatting.png

View solution in original post

7 Replies
tnewbie
Creator II
Creator II

TalendDate.isDate(incoming_row.incoming_col_value,"dd-MMM-yy") ? TalendDate.parseDate("dd-MMM-yy",incoming_row.incoming_col_value) : null and in the Date Pattern put the date format "mm/dd/yy" please see the attachment

 

Notes:

1) Your incoming value should be a string data type

2) your output port should be date data type


date_formatting.png
vapukov
Master II
Master II

Hi,

 

if you read the column with tFileInputDelimited as a Date and send it to the destination also as a Date, you do not need anything, just use different patterns. If your destination is a string - you need to use formatDate function (use tMap it contains a lot of predefined function templates)

https://help.talend.com/reader/nAXiZW0j0H~2~YApZIsRFw/JFWl8U3lEbhWZEFAUtYvMw 

tnewbie
Creator II
Creator II

Hi Vapukov,

If we read the source data column value as date and if the date pattern do not match (the format / pattern we supply) it throws out an error and the whole record will be rejected, if we read it as string and then try to format it the way i prescribed then atleast the record will not be rejected though the specific column value goes as null

 

Please correct me if i am wrong...

vapukov
Master II
Master II

Generally speaking - job will be failed in both ways. But you can read as a string and make pre-format checking before to call the function, it is a little more complicated but will not die the whole job
tnewbie
Creator II
Creator II

Sorry to defer on this...In my proposed solution job will NOT fail but will only return null value for that specific date column if the pattern doesn't match, that is the whole advantage we are trying to bring to the table. Thanks for the response though.

profuse
Creator
Creator
Author

Tnewbie,

 

OMG that worked.... your the best, THANK YOU!!!!

 

Profuse

tnewbie
Creator II
Creator II

Glad it worked for you...pls mark the issue as resolved so that it benefits some one else in need