【发布时间】:2018-02-02 13:17:03
【问题描述】:
您好,我正在尝试从 Postgres 中的时间戳中提取时间
SELECT extract(time from '2000-01-01 01:12:00'::timestamp)
结果应该是: 01:12:00
看起来那个时间不是提取的有效参数。对吗?
【问题讨论】:
标签: postgresql datetime time timestamp
您好,我正在尝试从 Postgres 中的时间戳中提取时间
SELECT extract(time from '2000-01-01 01:12:00'::timestamp)
结果应该是: 01:12:00
看起来那个时间不是提取的有效参数。对吗?
【问题讨论】:
标签: postgresql datetime time timestamp
select '2000-01-01 01:12:00'::timestamp::time
【讨论】:
试试这个:
s=# SELECT cast ('2000-01-01 01:12:00'::timestamp as time);
time
----------
01:12:00
(1 row)
不提取 - 那么,您可能想要使用 cast。
是的 - https://www.postgresql.org/docs/current/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
time 不是有效的 aprt
【讨论】: