0

I have been trying to fix this issue but could not find a solution to it.

I have a date column as string type . Trying to convert it to timestamp using date_parse but getting the following error.

INVALID_FUNCTION_ARGUMENT: Invalid format: "2021-09-28 21:05:28.272159" is malformed at "21:05:28.272159"

my query is

"date_parse"(a.commitdatetime, '%y-%m-%d %h:%i:%s.%f') commitdatetime

do you have any ideas how to fix this issue? Thanks for your time from now

jarlh
  • 42,561
  • 8
  • 45
  • 63
Erdal
  • 21
  • 2
  • https://prestodb.io/docs/current/functions/datetime.html#mysql-date-functions - See the `Specifier`s, the casing is important example (h and H mean 2 different things as do Y and y). – Igor Sep 20 '22 at 16:19
  • `parse_datetime` perhaps? – Andrew Sep 20 '22 at 16:20

1 Answers1

0

Please refer to format strings documentation. %y and %h should be substituted with %Y and %H correspondingly:

select date_parse('2021-09-28 21:05:28.272159', '%Y-%m-%d %H:%i:%s.%f');

Output:

_col0
2021-09-28 21:05:28.272
Guru Stron
  • 102,774
  • 10
  • 95
  • 132