Martin M
Martin M

Reputation:

Find Rows whose date range contain a given date

I am looking at the following problem:

My group table contains two fields: ArrivalDate and DepartureDate.

Now I want to find all groups who are present at a given date.

Eg. the SQL query is passed a date, and I want to find every group where this date falls into the range ArrivalDate to DepartureDate.

Thanks a lot! Martin

Upvotes: 1

Views: 1186

Answers (1)

VolkerK
VolkerK

Reputation: 96159

SELECT
  ...
FROM
  yourGroupTable as y
WHERE
  Curdate() BETWEEN y.ArrivalDate AND y.DepartureDate

replace Curdate() by your actual date value.

Upvotes: 4

Related Questions