0

Learning Hibernate's functionality and struck on a problem finding something, that would represent Oracle's:

trunc(someDate) < trunc(sysdate) // aka 01.02.2017 00... < 01.02.2017 00...

or a postgres representative:

date_trunc('day',someDate) < current_date

I guess there must be something in Hibernate's Criteria.

Draaksward
  • 759
  • 7
  • 32
  • 1
    Have a look at [“Generic” current time function using JDBC](http://stackoverflow.com/questions/23611467/generic-current-time-function-using-jdbc). You should be able to use JDBC escape functions in native (SQL) queries. – Mick Mnemonic Feb 01 '17 at 09:38
  • But how to do it using hibernates HQL? – Draaksward Feb 02 '17 at 09:59
  • You probably need to create a HQL query where you give the current date as a query parameter. – Mick Mnemonic Feb 02 '17 at 11:04

1 Answers1

0

in similar situation I used native query.

date_trunc('day', some_date)

or for the next day

date_trunc('day', some_date) + (interval '1 day')