I need to get today's items from database (more specifically PostgreSQL) using JPQL.
I need all the items that their day is the same as today. I tried this but it is not working because the current timestamp and creation timestamp are not exactly the same due to different times. It does not return any result.
@Query("select u from User u where u.timestamp = current_timestamp")
The question is how do I only compare the day?
CodePudding user response:
From today means from "00:00:00" until now?
select u from User u where u.timestamp > date_trunc('day', now());