两个时间戳之间的SQL

时间:2018-06-13 16:30:19

标签: java sql postgresql jpa spring-data-jpa

我有两列的表

(system-config-printer.py:4389): Gtk-WARNING **: 12:24:44.435: This
process is currently running setuid or setgid.
This is not a supported use of GTK+. You must create a helper
program instead. For further details, see:

    http://www.gtk.org/setuid.html

Refusing to initialize GTK+.

我需要在date_start和 TIMESTAMP + 3 HOUR 之间执行SELECT * booking_schedules TIMESTAMP(来自后端的参数) JPA QUERY IS

CREATE TABLE booking_schedules (
  date_start    TIMESTAMP
  date_end      TIMESTAMP,
);

其中 selectedTime是TIMESTAMP,selectedTime1是TIMESTAMP + 3 HOUR
在这种情况下,Select返回所有行。
所以麻烦(我认为)是将第二个参数设置为TIMESTAMP + 3 HOUR。有可能吗?如果是,那么如何?提前感谢您的答案。

1 个答案:

答案 0 :(得分:0)

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

这应该可以正常工作