Reputation: 1
I am trying to convert a timestamp string to timestamp with date_parse, but keep getting an error. Any suggestions? I am working on Presto SQL. I have tried to replace %H:%f
with %T
and it still doesn't work.
date_parse(sg."@timestamp", '%Y-%m-%d %H:%f')
The error message is:
presto: query failed (200 OK): "USER_ERROR: com.facebook.presto.spi.PrestoException: Invalid format: "2017-12-31 08:29:02.12" is malformed at ":02.12""
Any help would be greatly appreciated, thanks!
Upvotes: 0
Views: 1887
Reputation: 20710
You need date_parse()
with this format:
presto:default> SELECT date_parse('2017-12-31 08:29:02.12', '%Y-%m-%d %H:%i:%S.%f');
_col0
-------------------------
2017-12-31 08:29:02.120
(1 row)
Upvotes: 1