Home » RDBMS Server » Server Administration » java sql Timestamp and Oracle Date
java sql Timestamp and Oracle Date [message #372209] Thu, 18 January 2001 17:44 Go to next message
motiram
Messages: 21
Registered: January 2001
Junior Member
How to compare a java sql timestamp with Oracle date. I was trying to compare these 2, and I am getting weird problems.

SQL STATEMENT :
----------------

select count(*) from phonenumber where typeid = 1 and createddate >=2000-10-31 19:00:00.0 and createddate <= 2000-12-31 19:00:00.0 and StatusID = 5 or StatusID = 4

ERROR MSG:
----------
java.sql.SQLException: ORA-00933: SQL command not properly ended
Re: java sql Timestamp and Oracle Date [message #372210 is a reply to message #372209] Thu, 18 January 2001 19:58 Go to previous message
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
select count(*) from phonenumber where typeid = 1 and createddate >= to_date('2000-10-31 19:00:00.0', 'yyyy-mm-dd hh24:mi:ss..') and createddate <= to_date('2000-10-31 19:00:00.0', 'yyyy-mm-dd hh24:mi:ss..') and (StatusID = 5 or StatusID = 4)

The last "." in your input string is a little tricky to handle, but it seems ".." in the format picture fixes that. Be careful of the parentesis when you have an "or". You could also code it as StatusID in (4, 5) which is probably a little more efficient especially if the list gets long...
Previous Topic: Oracle Number data type
Next Topic: To check the refrential integrity between two tables?
Goto Forum:
  


Current Time: Sat May 18 01:57:52 CDT 2024