从 PostgreSQL 中的时间戳获取日期 [英] getting date from timestamp in PostgreSQL
本文介绍了从 PostgreSQL 中的时间戳获取日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 PostgreSQL 时间戳
I have a PostgreSQL timestamp as
2009-12-22 11:01:46
我需要将其更改为日期
2009-12-22
这样我就可以比较 postgreSQL
中的日期了
So that I can compare the dates in postgreSQL
我怎样才能实现这种转变?
How can I achieve this transformation?
推荐答案
将其转换为 date
.
SELECT yourtimestamp::date;
如果您需要提取其他类型的内容,您可能需要使用 EXTRACT 或 date_trunc
If you need to extract other kinds of stuff, you might want to use EXTRACT or date_trunc
两个链接都指向同一个页面,如果您会发现更多与日期/时间相关的功能.
Both links are to the same page, were you'll find more date/time-related functions.
这篇关于从 PostgreSQL 中的时间戳获取日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文