Thread: Re: [SQL] How to compare Datetime

Re: [SQL] How to compare Datetime

From
Tom Lane
Date:
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