Re: How to query a Date Column in SQL
From: Lee Fesperman (firstsql_at_ix.netcom.com)
Date: 08/19/04
- Next message: vejan: "Oracle & events"
- Previous message: kaeli: "Re: How to query a Date Column in SQL"
- In reply to: Laura P: "How to query a Date Column in SQL"
- Next in thread: Laura P: "Re: How to query a Date Column in SQL"
- Reply: Laura P: "Re: How to query a Date Column in SQL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 18 Aug 2004 23:25:07 GMT
Laura P wrote:
>
> I am in the process of refactoring a Java application which uses JDBC
> to talk to Oracle and MySQL. The old way used to have a DateTime
> field that was represented in the database as a text field, a typical
> query on this field would be: "Select * from Table1 where DateTime <=
> '2004/08/17 09:00:30'".
>
> In the new database schema, the DateTime field is represented as a
> Date field. My problem is that I have to parse my query text (which
> is not SQL :( ) and create a String from that, which is valid SQL.
> This happens in a different part of the application to the actual
> database connection, so I cannot use a PreparedStatement and insert
> the java.sql.Date value that way. I have found some information about
> sql date operators such as DATEDIFF, but not enough to make use of
> them, and I was not sure if these would work through the JDBC driver
> even if I managed to get them working...
>
> I would be very grateful for any information anyone has on this - I
> can't believe it is as difficult as I have found it today to create a
> data query SQL string!
Have you tried using the {d ...} escape sequence? It uses a standard date form that is
easy to create with DateFormat classes in java.text. Hopefully, both the Oracle and
MySQL JDBC drivers will support the escape sequence.
-- Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com) ============================================================== * The Ultimate DBMS is here! * FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)
- Next message: vejan: "Oracle & events"
- Previous message: kaeli: "Re: How to query a Date Column in SQL"
- In reply to: Laura P: "How to query a Date Column in SQL"
- Next in thread: Laura P: "Re: How to query a Date Column in SQL"
- Reply: Laura P: "Re: How to query a Date Column in SQL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|