Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.3K Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Import string dates using US date format?

Posted 6 years ago
POSTED BY: Andrew Burnett
4 Replies
Posted 6 years ago

That's great. Thank you very much.

POSTED BY: Andrew Burnett
Posted 6 years ago

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 *)
POSTED BY: Rohit Namjoshi
Posted 6 years ago
POSTED BY: Andrew Burnett
Posted 6 years ago

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 *)
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard