my dog learned polymorphism*
The moose likes Servlets and the fly likes SQL to retrieve date vals from ORA-DB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "SQL to retrieve date vals from ORA-DB" Watch "SQL to retrieve date vals from ORA-DB" New topic
Author

SQL to retrieve date vals from ORA-DB

Rao Nadella
Greenhorn

Joined: Jan 19, 2001
Posts: 16
Hello Friends,
I am trying to retrieve info from the Oracle DB, with a SQL statement which looks something like:
Select * from tblORA
where tblDate = ('myDate','MMDDYYYY')
Can myDate be of type String? I am trying to retrieve a date
of String type from another page and insert that date into
the SQL statement.
What would be a good way so that the Date that I retrieve from
a previous page is of correct type and be included in the SQL statement.
Thanks a bunch
-Rao
prabhatis
Greenhorn

Joined: Apr 07, 2001
Posts: 18
u do something like this :
String sDate = "TO_DATE('"+myDate+"','DD.MM.YYYY')";
now Query= "select * from tablename where datecol="+sDate;
hope it will help lemme know
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SQL to retrieve date vals from ORA-DB
 
Similar Threads
Question for insertint to Date field.
JDBC and smalldatetime - ms sql server 2008
why get different result in different java version
Convert from String to java.sql.Date
Optional parameters in EJB QL?