0

I have a JPA mapped "event" object that includes a timestamp column. I am trying to select all events that occurred on a specific date. To do this I need to ignore the time component of the timestamp. I am not sure that this is possible using non database specific functions? Something like this fails to select:

@Query("SELECT r FROM BioChemRequest r WHERE r.pasId = :pasid AND r.observationDate BETWEEN :startDate AND :startDate") public List <BioChemRequest> find(@Param("pasid") String pasid , @Param("startDate") Date startDate); 

1 Answer 1

1

try the following

@Query("SELECT r FROM BioChemRequest r WHERE r.pasId = :pasid AND r.observationDate BETWEEN :startDate AND :endDate") public List <BioChemRequest> find(@Param("pasid") String pasid , @Param("startDate") Calendar startDate, @Param("endDate") Calendar endDate); 

where startDate is a calendar with hour 00:00:00 000

and endDate is a calendar with hour 23:59:59 999

Sign up to request clarification or add additional context in comments.

1 Comment

Perfect - thank you. In fact it inspired me to convert the code to use LocalDateTime

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.