Import string dates using US date format?

I have imported a log file that contains dates in (M/D/Y) format. Because the dates are in June,

DateObject[#]&

Reports that the date string is ambiguous. How might I tell the Notebook - not the whole mathematica system - the date format of the file?

I tried

DateObject[#, DateFormat -> {"Month", "/", "Day", "/", "Year"}] & 

But it didn’t have any effect on the warming messages.

Thanks
Andy

Hi Andrew,

To parse a date string in M/D/Y format:

d = DateObject[{"6/10/2019", {"Month", "/", "Day", "/", "Year"}}]
DateString[d, "ISODateTime"]
(* 2019-06-10T00:00:00 *)

Hi Rohit,
Thanks for your answer. Unfortunately, I can’t get it to work, and I am obviously doing something dumb. Just to be clear, I am importing a csv log file that contains dates in the format 06/11/2019 10:55:44 AM. I want to convert them to DateObjects. The conversion does work, but it complains that it is ambiguous. Adding the format list, as you suggested, produces a “cannot be interpreted as a date.” message

Here is the code snippet - can you see what I am doing wrong?

ecicc = Import[“/Users/andy/Downloads/participants_497478659.csv”];
In[65]:= ecicc[[2, 3]]
Out[65]= “06/11/2019 10:55:44 AM”
ecicc[[2 ;; All, 3]] = DateObject[{#, {“Month”, “/”, “Day”, “/”, “Year”, “hour”, “:”,
“Minute”, “:”, “Seconds”}}] & /@ ecicc[[2 ;; All, 3]];
ecicc[[2 ;; All, 4]] = DateObject[{#, {“Month”, “/”, “Day”, “/”, “Year”, “hour”, “:”,
“Minute”, “:”, “Seconds”}}] & /@ ecicc[[2 ;; All, 4]];
DateObject::str: String 06/11/2019 10:58:51 AM cannot be interpreted as a date.
General::stop: Further output of DateObject::str will be suppressed during this calculation.
DateObject::str: String 06/11/2019 12:54:08 PM cannot be interpreted as a date.
General::stop: Further output of DateObject::str will be suppressed during this calculation.

Andrew,

The pattern has to match exactly

d = DateObject[{"06/11/2019 10:55:44 AM", {"Month", "/", "Day", "/", 
    "Year", " ", "Hour12", ":", "Minute", ":", "Second", " ", "AMPM"}}];
DateString[d, "ISODateTime"]
(* 2019-06-11T10:55:44 *)

Change AM to PM

d = DateObject[{"06/11/2019 10:55:44 PM", {"Month", "/", "Day", "/", 
    "Year", " ", "Hour12", ":", "Minute", ":", "Second", " ", 
    "AMPM"}}];
DateString[d, "ISODateTime"]
(* 2019-06-11T22:55:44 *)

That’s great. Thank you very much.