This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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 REST with Spring (video course) this week in the Spring 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
I agree. Here's the link:
subject: Data Type Conversion(urgent)
It's not a secret anymore!