• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data Type Conversion(urgent)

 
Chhaya Dhanani
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
Please reply to my query. This is a SOS.
I need it urgently
Thanx in advance
 
Alex Kravets
Ranch Hand
Posts: 476
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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,
Alex
 
prabhat kumar
Ranch Hand
Posts: 114
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic