Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes JDBC and Relational Databases and the fly likes Data Type Conversion(urgent) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Data Type Conversion(urgent)" Watch "Data Type Conversion(urgent)" New topic

Data Type Conversion(urgent)

Chhaya Dhanani
Ranch Hand

Joined: Apr 11, 2001
Posts: 70
Hi All,
I am passing a select query to oracle which goes like this:
Result rs=stmt.executeQuery(select * from customer where creation_date > '"+ fromDate +"' and creation_date < '"+ toDate+ "'");
I am geeting an SQLException saying Data Type Mismatch.
The creation_date is a varchar type in Oracle.
The user enters the fromDate and the toDate from the DosPrompt in the following format: yyyyddmmhhmmss(year,day,month,hour,minute,seconds)
Please let me know whether i can use less than(<) and greater than sign (>) with varchar datattype
Thanx in advance
Chhaya Dhanani
Ranch Hand

Joined: Apr 11, 2001
Posts: 70
Hello All,
Please reply to my query. This is a SOS.
I need it urgently
Thanx in advance
Alex Kravets
Ranch Hand

Joined: Jan 24, 2001
Posts: 476
I am thinking that since you are basically comparing String objects, you can't use ">" or "<". Try converting the values you get for dates into integers: Integer.parseInt(). Or instead of ">" or "<" use LIKE in SQL statement.
Hope this helps,

All right brain, you don't like me and I don't like you, but let's just do this one thing so I can get back to killing you with beer.<br /> <br />- Homer Simpson
prabhat kumar
Ranch Hand

Joined: Apr 11, 2001
Posts: 114
use something like this
String sDate = "TO_DATE('"+fromdate+"','DD.MM.YYYY')";
and now u can use this sDate in ur query to comapre ..
hope it woll work for u
Prabhat kumar
subject: Data Type Conversion(urgent)