Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a PostgreSQL timestamp as

2009-12-22 11:01:46

I need to change this to date as

2009-12-22

So that I can compare the dates in postgreSQL

How can I achieve this transformation?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
793 views
Welcome To Ask or Share your Answers For Others

1 Answer

Cast it to date.

SELECT yourtimestamp::date;

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...