String to Date Parsing Issue

0
Hello Everyone, I am having an issue with parsing or converting string into date. Input String: 12/3/2018 8:47:32 AM  I am currently using the following function to convert that parseDateTime($Iteratorchemistry_content_1/uc_WorkflowDate,'mm-dd-yyyy hh:mm:ss',empty) But this statement causes all the conversion to get empty Desired Output: 12/3/2018  When I use the following statement, I get run-time error: parseDateTime($Iteratorchemistry_content_1/uc_WorkflowDate,'mm-dd-yyyy I am not sure how to proceed. Could anyone please advise. Thanks a lot in advance. Best Regards, Lidan Zhang
asked
2 answers
2

To add one change to Tim’s answer, I think you’ll need the letter a at the end of the second argument (which denotes AM/PM), so it would look like this:  parseDateTime($Iteratorchemistry_content_1/uc_WorkflowDate,'mm/d/yyyy hh:mm:ss a',empty)  Without the a, the parse function won’t know if a the time in your example is 8 in the morning or 8 in the evening.  You can also omit the third argument (empty) for brevity.

One more link that documents all possible date formatting characters:  https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html 

answered
1

You should use /d/ instead of -dd-. This is the correct one: parseDateTime($Iteratorchemistry_content_1/uc_WorkflowDate,'mm/d/yyyy hh:mm:ss',empty)

See https://docs.mendix.com/refguide/parse-and-format-date-function-calls for the description

See https://mydemoversion8-sandbox.mxapps.io/p/ff/ParseDateTime for experimenting with formats

 

answered