Re: Comparing database dates: SELECT FROM WHERE Date(today) < MYDATECOL ?
voigt_at_ynnor.de
Date: 02/10/05
- Next message: Richad Fallon: "Re: Sybase, JDBC, AutoCommit, DDL IN TRAN"
- Previous message: voigt_at_ynnor.de: "Hibernate + Tomcat - where to bind the session to?"
- In reply to: Thomas Stein: "Comparing database dates: SELECT FROM WHERE Date(today) < MYDATECOL ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 10 Feb 2005 11:06:07 -0800
thosteno5pam@email.com (Thomas Stein) wrote in message news:<cu8g6g$vn7$00$1@news.t-online.com>...
> The resulting code should look similar to:
>
> java.util.Date somejavadate = new java.util.Date();
> java.sql.Date somesqldate = new java.sql.Date(somejavadate);
>
> rs = stmt.executeQuery("SELECT ... FROM ... WHERE " + somesqldate + "<= MYDATECOL");
>
> MYDATECOL is defined with a type "datetime".
>
> However this does not work.
> How does the exact query look like?
I would try it with prepared Statement:
PreparedStatement pStmt = conn.prepareStatement("select ... from ...
where ?<=MYDATECOL");
pStmt.setTimestamp(1, new
java.sql.Timestamp(System.currentTimeMillis());
rs = stmt.executeQuery();
Greetings Bastian
- Next message: Richad Fallon: "Re: Sybase, JDBC, AutoCommit, DDL IN TRAN"
- Previous message: voigt_at_ynnor.de: "Hibernate + Tomcat - where to bind the session to?"
- In reply to: Thomas Stein: "Comparing database dates: SELECT FROM WHERE Date(today) < MYDATECOL ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]