Re: [SQL] How to compare Datetime - Mailing list pgsql-sql

From Tom Lane
Subject Re: [SQL] How to compare Datetime
Date
Msg-id 23586.924363991@sss.pgh.pa.us
Whole thread Raw
List pgsql-sql
Henrik Pedersen <HenrikP@utp.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


pgsql-sql by date:

Previous
From: Ady-55
Date:
Subject: ...
Next
From: david
Date:
Subject: Impossible query with SQL? or not?