Search code examples
jpajbossjpql

How to compare timestamp with date without time in JPQL?


I'd like to get objects with create_date = :my_date where create_date is in 2014-12-02 14:49:15.029 format and my_date is in 2014-12-02 format in JPA.

Is there any way to compare timestamp column with Date object (yyyy-MM-dd format) in JPQL using NamedQuery or should I use native query?


Solution

  • If you are using jpql try to use

    date(timestamp_column) 
    

    eg :

    @Query(select te from Testentity te where date(te.createdTimestamp) >= CURRENT_DATE)
     public List<Testentity> getTestDate()