Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting timestamp(string) to date(dddd-mm-yy) in presto

Tags:

presto

trino

I have a timestamp value in a varchar column. the value looks like below.

2020-10-31T23:36:03.000+0000

I want to convert this to below for using it in my query filter.

2020-10-31

I tried using date_parse and split_part:

SELECT date_parse('2020-06-30T17:17:35.000+0000','%Y-%m-%d %H:%i:%s:%f') as xy and

where cast(split_part('2020-06-30T17:17:35.000+0000', ' ', 1) as date) >= date '2020-06-30'

Both return error saying:

presto error: Invalid format: "2020-06-30T17:17:35.000+0000" is malformed at "T17:17:35.000+0000"

Can someone point me in the right direction?

like image 409
jahan Avatar asked Sep 16 '25 04:09

jahan


1 Answers

Using this solved my problem

cast(from_iso8601_timestamp('2020-06-30T17:17:35.000+0000') as DATE) >= date '2020-06-30'

like image 71
jahan Avatar answered Sep 19 '25 17:09

jahan