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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Parse String to Date

Hi All,
I have situation where I want to convert String to Date.
I tested first without parsing anything. It looks like this :

Source : 8/5/2012 3:27:06 PM
Result : Tue May 08 15:27:06 SGT 2012

Mind you that both are Strings.
Do you have any idea on how to convert String to Date. So that the Result datatype is Date not String.
Thanks in advance,
Regards,
naim
0683p000009MDmF.jpg
Labels (2)
4 Replies
Anonymous
Not applicable
Author

hi sonal,
I Have tried using TalendDate.parseDate("dd/MM/yyyy HH:mm:ss",row1.Value) and the result is
Starting job UC_Pro_Preparation at 09:27 08/02/2013.

connecting to socket on port 3935
connected
Exception in component tMap_1
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "row1.pa_record_create_date"
at routines.TalendDate.parseDate(TalendDate.java:744)
at talend.uc_pro_preparation_0_1.UC_Pro_Preparation.tFileInputExcel_1Process(UC_Pro_Preparation.java:1956)
at talend.uc_pro_preparation_0_1.UC_Pro_Preparation.runJobInTOS(UC_Pro_Preparation.java:2404)
at talend.uc_pro_preparation_0_1.UC_Pro_Preparation.main(UC_Pro_Preparation.java:2272)
Caused by: java.text.ParseException: Unparseable date: "row1.pa_record_create_date"
at java.text.DateFormat.parse(Unknown Source)
at routines.TalendDate.parseDate(TalendDate.java:742)
... 3 more
disconnected
Job UC_Pro_Preparation ended at 09:27 08/02/2013.
Do you have any idea what is going wrong with the job?
Thank you.
0683p000009MDd8.jpg
Anonymous
Not applicable
Author

Hi Naim,
One of the method to achieve this is by changing the data type from the edit schema option.
# Double click on the tLogRow Component
# Click on the edit schema option
# Select the column which data type needs to be change
# Change the data type form the drop down list available in the type column
# Make these change in both the ends i.e. tLogRow as well as tFileInputExcel
# You can also mention the desired pattern of the date in the Date pattern column
For more details have a look in the attached snapshot.
Best Regards,
Mayur
0683p000009MDn2.jpg
_AnonymousUser
Specialist III
Specialist III

These examples work:
TalendDate.parseDateLocale("d/M/yyyy HH:mm:ss a",
"8/5/2012 3:27:06 PM","EN")
TalendDate.parseDateLocale("EEE MMM dd HH:mm:ss z yyyy",
"Tue May 08 15:27:06 SGT 2012","EN")

for your source, you would use:
TalendDate.parseDateLocale("d/M/yyyy HH:mm:ss a",row1.pa_record_create_date,"EN")
Anonymous
Not applicable
Author

Hi,
Thank you so much.
Regards,
naim