0

I have table with 2 columns

CREATE TABLE booking_schedules (
  date_start    TIMESTAMP
  date_end      TIMESTAMP,
);

I need to do SELECT * booking_schedules where TIMESTAMP(parameter from back-end) between date_start and TIMESTAMP+3 HOUR
JPA QUERY IS

@Query(value = "select bs from BookingSchedule bs :chosenTime between bs.dateStart and :chosenTime1")
    List<BookingSchedule> findAllBookingSchedulesByDateBetweenDateStartAndDateEnd(@Param("chosenTime") Date chosenTime,@Param("chosenTime1") Date chosenTime1);

Where chosenTime is TIMESTAMP and chosenTime1 is TIMESTAMP + 3 HOUR
In this case Select returns all rows.
So trouble(i think) is to set 2-nd parameter as TIMESTAMP+3 HOUR. Is is possible? If yes then how?Thanks in advance for answers.

1 Answers1

0
SELECT * 
FROM booking_schedules 
WHERE TIMESTAMP_x between date_start and 
TIMESTAMP_x +
INTERVAL '3 hours' 

This should work fine