Re: [SQL] How to compare Datetime

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Henrik Pedersen <HenrikP(at)utp(dot)dk>
Cc: pgsql-sql(at)hub(dot)org
Subject: Re: [SQL] How to compare Datetime
Date: 1999-04-17 15:46:31
Message-ID: 23586.924363991@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Henrik Pedersen <HenrikP(at)utp(dot)dk> writes:
> Im having some problems with the datetime fields

datetime is a date and time, not just a date. The behavior you describe
is all perfectly correct once you realize that your constants are being
interpreted as midnight of the given date.

If you only want to store the date, and not the time of day, your column
datatype should be "date" not datetime.

If you do want to store an exact time, then datetime is the right thing
to use. You can perform tests on it with one-day resolution by using
the date_part function to extract just the date. See the User's Guide.

regards, tom lane

Browse pgsql-sql by date

  From Date Subject
Next Message Ady-55 1999-04-17 20:49:59
Previous Message Daniele Orlandi 1999-04-16 21:23:56 Strange behaviour with date costants....