如何将以下字符串转换为日期或时间戳?

How to cast the following string to a date or timestamp?

我在 table 中有这样的字符串:

2020-11-16 03:46:26.007+00

我正在尝试将这些转换为日期,以便我可以从中提取日期 (2020-11-16)。

SELECT date_parse(updatedat,'%Y-%m-%d %h:%i:%s.%f+%x') FROM table LIMIT 10 

可惜了 returns: 0000-11-16 03:27:13.017

将此字符串转换为我可以提取所需部分的日期或时间戳的正确方法是什么?

该字符串遵循时间戳的规范格式,因此您应该能够将其转换为 timestamp 类型,然后再转换为 date:

> select cast(cast('2020-11-16 03:46:26.007+00' as timestamp) as date);
   _col0
------------
 2020-11-16
(1 row)