tags:

views:

146

answers:

1

Hello,

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

+3  A: 
SELECT
  ...
FROM
  yourGroupTable as y
WHERE
  Curdate() BETWEEN y.ArrivalDate AND y.DepartureDate

replace Curdate() by your actual date value.

VolkerK
Thanks a lot! I did not know that one could swap the WHERE and BETWEEN parameters, meaning that WHERE does not always have to be followed by a column name!