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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Converting a date and time string to a date format

I have a csv source file where the date coming in is a string format:  4/26/2013 11:07:05 PM

I need to convert this to a date format or 2013-04-26

 

I can't seem to get the basic functions to work.  Do I need to parse out the 'PM' first?

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi
You can call the built-in function to do it on tMap, eg:
TalendDate.parseDate("M/dd/yyyy hh:mm:ss a", row1.columnName)

Regards
Shong

View solution in original post

3 Replies
Anonymous
Not applicable
Author

This should work

SimpleDateFormat sdf = new SimpleDateFormat("M/dd/yyyy hh:mm:ss a");
Date d = sdf.parse("4/26/2013 11:07:05 PM"); sdf.applyPattern("yyyy-MM-dd"); String newDateString = sdf.format(d); //2013-04-26
Anonymous
Not applicable
Author

I was originally trying to do this in a tMap expression.  Would I use tJava to execute the script provided?

 

Anonymous
Not applicable
Author

Hi
You can call the built-in function to do it on tMap, eg:
TalendDate.parseDate("M/dd/yyyy hh:mm:ss a", row1.columnName)

Regards
Shong