Re: Comparing database dates: SELECT FROM WHERE Date(today) < MYDATECOL ?
From: Dotty (Dotty_at_nospam.invalid)
Date: 02/07/05
- Next message: Ryan Stewart: "Re: Comparing database dates: SELECT FROM WHERE Date(today) < MYDATECOL ?"
- Previous message: Bjorn Abelli: "Re: Comparing database dates: SELECT FROM WHERE Date(today) < MYDATECOL ?"
- In reply to: Thomas Stein: "Comparing database dates: SELECT FROM WHERE Date(today) < MYDATECOL ?"
- Next in thread: Ryan Stewart: "Re: Comparing database dates: SELECT FROM WHERE Date(today) < MYDATECOL ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 7 Feb 2005 16:35:47 -0600
"Thomas Stein" <thosteno5pam@email.com> wrote in message
news:cu8g6g$vn7$00$1@news.t-online.com...
> I want to get in a java prgm all those database records whose MYDATE
column contains a
> date greater equal a given other date (say: today). How do I specify this
> in a SQL query from Java?
>
> Assume the comparison date in java is in a java.util.Date field. Do I have
to convert it
> into a variable of type java.sql.Date?
>
> 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?
>
> Is the date query database product specific?
>
> Thomas
>
Try google, I found this via google:
Datetime Arithmetic in SQL
The only arithmetic operations that can be performed on datetime values are
addition and subtraction. If a datetime value is the operand of addition,
the other operand must be a duration. The specific rules governing the use
of the addition operator with datetime values follow. .....
- Next message: Ryan Stewart: "Re: Comparing database dates: SELECT FROM WHERE Date(today) < MYDATECOL ?"
- Previous message: Bjorn Abelli: "Re: Comparing database dates: SELECT FROM WHERE Date(today) < MYDATECOL ?"
- In reply to: Thomas Stein: "Comparing database dates: SELECT FROM WHERE Date(today) < MYDATECOL ?"
- Next in thread: Ryan Stewart: "Re: Comparing database dates: SELECT FROM WHERE Date(today) < MYDATECOL ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|