Message Boards Message Boards

GROUPS:

Interpret a standard date format with SemanticInterpretation?

Posted 7 days ago
89 Views
|
2 Replies
|
0 Total Likes
|

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

2 Replies

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

I suspected that.

Thank you Henrik.

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