Re: Date types in where clause of PreparedStatement

From: "Gregory Wood" <gregw(at)com-stock(dot)com>
To: "Ian deSouza" <iandesouza(at)earthlink(dot)net>
Cc: "PostgreSQL-General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Date types in where clause of PreparedStatement
Date: 2001-02-23 03:13:21
Message-ID: 003801c09d46$d1abc260$7889ffcc@comstock.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Using a DateTime value in a WHERE clause is not a good idea for the reason
that DateTimes are usually represented by a floating point value in the
database itself. And since floating point numbers are prone to rounding
errors, they don't make for a good unique identifier.

If you have to use dates in your WHERE clauses, try doing a BETWEEN.

Greg

----- Original Message -----
From: "Ian deSouza" <iandesouza(at)earthlink(dot)net>
To: <pgsql-general(at)postgresql(dot)org>
Sent: Sunday, February 18, 2001 11:17 AM
Subject: Date types in where clause of PreparedStatement

> Can anybody show any reason why the code using a prepared statement with a
> where clause using a date won't find any records on PostgreSQL but WILL
work
> using Access and the jdbc-odbc bridge?
>
> ie.
>
> SQL: select
>
OrderID,CustomerID,EmployeeID,OrderDate,RequiredDate,ShippedDate,ShipVia,Fre
> ight,ShipName,ShipAddress,ShipCity,ShipRegion,ShipPostalCode,ShipCountry
> from Orders where OrderDate = ?
> Setting value: OrderDate 1996-07-05 00:00:00.0
>
> It does not cause an exception, but fails to retrieve anything with
> PostgreSQL yet works and retrieves the right record with Access.
>
> I further verified that a record does exist with the PostreSQL database.
>
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message He Weiping(Laser Henry) 2001-02-23 03:14:12 Re: [HACKERS] Re: [INTERFACES] Re: Chinese patch for Pgaccess
Previous Message Thyagarajan Vasudevan 2001-02-23 02:30:18 Re: install problem.