How to query a Date Column in SQL
From: Laura P (laura.paterson_at_gmail.com)
Date: 08/18/04
- Next message: Fredrik Bertilsson: "Re: Java database app. example ?"
- Previous message: ccc31807: "Re: postgreSQL v. MySQL?"
- Next in thread: kaeli: "Re: How to query a Date Column in SQL"
- Reply: kaeli: "Re: How to query a Date Column in SQL"
- Reply: Lee Fesperman: "Re: How to query a Date Column in SQL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 18 Aug 2004 09:34:17 -0700
Hi,
I'm sorry if this is a very noddy question, but I seem to have a block
on how to do this...
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!
Many thanks,
Laura
- Next message: Fredrik Bertilsson: "Re: Java database app. example ?"
- Previous message: ccc31807: "Re: postgreSQL v. MySQL?"
- Next in thread: kaeli: "Re: How to query a Date Column in SQL"
- Reply: kaeli: "Re: How to query a Date Column in SQL"
- Reply: Lee Fesperman: "Re: How to query a Date Column in SQL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|