SQL:从我的SQL查询的日期值减去1天

时间:2013-08-31 13:03:59

标签: mysql sql

我有这个问题:

SELECT * FROM booking WHERE '$year/$month/$day' BETWEEN arrivalDate AND departureDate

其中arrivalDate和departureDate是我的表格列中的日期值。

如何在出发前一天检查日期?

IE:departureDate - 1天

1 个答案:

答案 0 :(得分:4)

你几乎就在那里,有 - INTERVAL 1 DAY

SELECT * FROM booking WHERE '$year/$month/$day' BETWEEN arrivalDate AND departureDate - INTERVAL 1 DAY

Relevant sqlFiddle here

另见: