无法从时间戳 Postgres 中提取时间

Han*_*gon 5 postgresql time datetime timestamp

嗨,我试图从 Postgres 的时间戳中提取时间

SELECT extract(time from '2000-01-01 01:12:00'::timestamp)
Run Code Online (Sandbox Code Playgroud)

结果应该是:01:12:00

看起来那个时间不是提取的有效参数。那正确吗?

Clo*_*eto 10

select '2000-01-01 01:12:00'::timestamp::time
Run Code Online (Sandbox Code Playgroud)


Vao*_*sun 7

尝试这个:

s=# SELECT cast ('2000-01-01 01:12:00'::timestamp as time);
   time
----------
 01:12:00
(1 row)
Run Code Online (Sandbox Code Playgroud)

不提取 - 那么,您可能想要使用cast.

是的 - https://www.postgresql.org/docs/current/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT

time 不是有效的 aprt