Wrox Programmer Forums
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 2nd, 2005, 08:39 AM
Registered User
 
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Comparing Dates

Hi.

I have created a table in oracle with the following a field end_date with the type DATE.

in one of my JSP pages, what i want to do is retrieve all of the records in that table that have an end_date > than the current date.
(so i have set up a variable to catch the current date using java.util.Date()).

what i cant do is compare them in my SELECT statement.
i get the following:

SQL> select end_date from gst where end_date >= 06/15/05;
select end_date from gst where end_date >= 06/15/05
                                        *
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected DATE got NUMBER

i also tried:
select gst_rate from gst where end_date > To_Date(01/01/05, 'DD/MM/YY');
but got the error:
ERROR at line 1:
ORA-01858: a non-numeric character was found where a numeric was expected

what do i need to do to be able to get a result from the query?
what im trying to do is get a listing of dates that are after the current date, and then determine which is the closest to the current date. then i can use other data in the table relating to this date.

any help or ideas would be great!
BB


 
Old April 3rd, 2005, 09:31 PM
Authorized User
 
Join Date: Apr 2005
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

JHELLo, well
in my oracle 9.x i use the date with this format yyyy-mm-dd and works

the error is for syntax but of oracle, i.e

select * from prueba where FECHA=2005-06-06 from dual;

from dual is not the solution, but is a trick of oracle that i saw in some cases
that is nessesary the use for example
select sysdate from dual;
, ask ORACLE FORUM, for the correct syntax,is not a java problem







Similar Threads
Thread Thread Starter Forum Replies Last Post
comparing dates help. warhero XSLT 1 July 5th, 2007 09:41 AM
Comparing dates Tomi XSLT 1 September 21st, 2006 04:45 AM
Comparing Dates in XSLT kwilliams XSLT 7 December 1st, 2005 08:49 PM
Help comparing dates Dave Brown Beginning PHP 3 December 20th, 2004 04:03 PM
Comparing Dates Issue tdaustin Classic ASP Basics 2 June 2nd, 2004 06:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.