How to compare Datetime

From: Henrik Pedersen <HenrikP(at)utp(dot)dk>
To: pgsql-sql(at)postgresql(dot)org
Subject: How to compare Datetime
Date: 1999-04-16 16:38:13
Message-ID: 3718111689.8543HENRIKP@mail.ikasths.dk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi...

Im having some problems with the datetime fields

Here is an example:
+----------------------------------+----------------------------------+-------+
| Field | Type | Length|
+----------------------------------+----------------------------------+-------+
| id | int4 | 4 |
| fornavn | text | var |
| tilmelddato | datetime | 8 |
+----------------------------------+----------------------------------+-------+

I want to select the entries that came in to the database 15 days ago.
tilmelddato contains the date that the entry was entered.

I do a "select * from testtable where tilmelddato = '01/04/1999'"
but that doesn't return anything even though my database contains
2 entries for that day.

If a do a "select * from testtable where tilmelddato > '01/04/1999'" it
returns 6 hits, but 2 of the hits was entered on the 01/04/1999 and
should not be in there, because of the >.

But if i use the < sign it works as i should. But if i do this:
"Select * from testtable where tilmelddato <= '15/04/1999'" the records
with 15/04/1999 is NOT included in the result set.

Im a bit confused about this .. the = dosnt work, the > and < works
partly


Im running Redhat 5.2 with kernel 2.2.4 and postgresql-6.4.2

Hope someone out there knows the answer :)

With friendly regards

Henrik Pedersen
Denmark

Browse pgsql-sql by date

  From Date Subject
Next Message Dr. Alexey A. Terent'ev 1999-04-16 18:38:00 php for pgsql for windows
Previous Message Jackson, DeJuan 1999-04-16 16:35:21 RE: [SQL] UPDATE subselect?