Home » Support » Forum » Using date in where clause

Using date in where clause

#1

I am trying to build a SELECT query as follows.

SELECT p FROM Persons p WHERE creationDate="07-25-2013"

Here I have created Persons object as java.sql.Date attribute.

 

But in doing so I am getting following exception

Operand type mismatch for operator '=' (error 757)
(position 51) at com.objectdb.jpa.JpaQuery.getResultList(JpaQuery.java:695)

 

Can someone provide me that way to build a query with date in where clause.

#2

The query is invalid because you compare a date (the creationDate field) with a string literal
("07-25-2013"). Replace the string with a date literal or a parameter.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login