I have a string that looks like:
2022-03-30 17:18:09.569000
I am trying to convert this to a timestamp as follows:
select "date_parse"("date_format"('2022-03-30 17:18:09.569000', '%Y-%m-%dT%h:%iZ'), '%Y-%m-%dT%h:%iZ')
but i keep getting an error:
Unexpected parameters (varchar(26), varchar(15)) for function date_format. Expected: date_format(timestamp with time zone, varchar(x)) , date_format(timestamp, varchar(x))
Advertisement
Answer
The value in your example matches the format of timestamp literals in SQL, so you can convert it to a timestamp
type by just casting the value to the desired type:
> select cast('2022-03-30 17:18:09.569000' as timestamp(6)); _col0 ---------------------------- 2022-03-30 17:18:09.569000 (1 row)