faqts : Computers : Programming : Languages : PHP : Database Backed Sites : Postgres

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

16 of 68 people (24%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

about date comparison

Dec 9th, 2002 09:04
Jonathan Ellis, Brett Stoppel, Sandis Jerics,


You can compare date and timestamp values directly:

select date1 > date2

To do date arithmetic, use intervals:

select date1 + '2 days'::interval

To compare just part of the date, use the date_part function, e.g. 

select date_part('day', now()) -- day of the month

select date_part('epoch', now()) -- date in seconds since unix epoch