Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

string to date

Hi,
I have a string like that "16/01/2008 09:04:12 AM" and i need to have a date from this string.
i try with TalendDate.parseDate("dd/MM/yyyy HH:mm:ss aa", madate) but it doesn't work.
the log is Unparseable date: "16/01/2008 09:04:12 AM"
Have u got an idea to help me ?

Labels (2)
20 Replies
Anonymous
Not applicable
Author

I tried your date string with your format and it works for me. Maybe you have problems with your Locale.
For a quick test just generate a date with your format and make a visual compare.
Bye
Volker
Anonymous
Not applicable
Author

Hi besco
Try this method:
TalendDate.parseDateLocale("dd/MM/yyyy HH:mm:ss aa",mydate,"EN")
Best regards
shong
Anonymous
Not applicable
Author

it's ok now but another problem appears when i load my date in oracle. if i have 2 date like that
16/01/2008 09:04:12 AM
16/01/2008 09:04:12 PM
there's no difference in oracle.
About date, i've another question, how can i put a default value (date of day) for a oracle column.
i try in a tmap to put this
row1.ORIGINAL_FILE_DATE.equals("null") ? TalendDate.getDate("dd/MM/yyyy hh:mm:ss") : row1.ORIGINAL_FILE_DATE

and the syntax seems to be wrong.
thanks to help me!
Anonymous
Not applicable
Author

have you got any idea please ?
Anonymous
Not applicable
Author

Hello
row1.ORIGINAL_FILE_DATE.equals("null") ? TalendDate.getDate("dd/MM/yyyy hh:mm:ss") : row1.ORIGINAL_FILE_DATE

There is no wrong on the syntax, if there are some fileds are empty in Oracle table, you can try this code:
row1.ORIGINAL_FILE_DATE==null ? TalendDate.getDate("dd/MM/yyyy hh:mm:ss") : row1.ORIGINAL_FILE_DATE

Best regards
shong
Anonymous
Not applicable
Author

this code is wrong
Exception in thread "Main Thread" java.lang.Error: Unresolved compilation problem: 
Type mismatch: cannot convert from Object&Serializable&Comparable to Date
Anonymous
Not applicable
Author

Hi
What's the schema type of row1.ORIGINAL_FILE_DATE in your case? I thought it was string, not Date.
If it is a Date type, we should parse a string to a Date.
row1.ORIGINAL_FILE_DATE==null ? TalendDate.parseDate("dd/MM/yyyy hh:mm:ss",TalendDate.getDate("dd/MM/yyyy hh:mm:ss") 😞 row1.ORIGINAL_FILE_DATE

Best regards
shong
Anonymous
Not applicable
Author

Shong
I am getting the following error when I tried using the expression in tMap, row1.START_DATE_ACTIVE==null ? TalendDate.parseDate("dd/MM/yyyy hh:mm:ss",TalendDate.getDate("dd/MM/yyyy hh:mm:ss") 😞 row1.START_DATE_ACTIVE.
ErrorMessage:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Can you please let me know how I can avoid this error. Thanks in advance.
-Venkat
Anonymous
Not applicable
Author

Shong,
I figured out the issue. This thread helped me to fix my issue.
Thank you,
-Venkat