Message Boards Message Boards

Interpret a standard date format with SemanticInterpretation?

Posted 5 years ago

I find the following a little disappointing:

SemanticInterpretation["2019-Feb-17 00:15:06.745140"]

which produces:

$Failed

Similarly for:

Interpreter["DateTime"][["2019-Feb-17 00:15:06.745140"]

and

Interpreter["Date"]["2019-Feb-17 00:15:06.745140"]

Is there a quick way to get Semantic... to recognize the date/time semantics in the string "2019-Feb-17 00:15:06.745140" ?

Thanks,

Vince

POSTED BY: Vincent Virgilio
2 Replies

I suspected that.

Thank you Henrik.

POSTED BY: Vincent Virgilio

Hi Vincent,

the decimals of the seconds seem to be the problem. If you cut them off then it works, e.g.:

datestring = "2019-Feb-17 00:15:06.745140";
getDateTime[s_String] := SemanticInterpretation[StringTrim[s, "." ~~ __]];

getDateTime[datestring]

I do admit that this is not really satisfying, regards -- Henrik

POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract