A family of Microsoft relational database management systems designed for ease of use.
The following function will identify intersecting date/time ranges:
Public Function WithinDateRange(dtmParamRangeStart As Date, _
dtmParamRangeEnd As Date, _
dtmDataRangeStart As Date, _
dtmDataRangeEnd As Date) As Boolean
' Accepts: date at which parameter range starts
' date at which parameter range ends
' date at which data range starts
' date at which data range ends
' Returns: True if data range intersects with parameter range
' False if whole of data range outside parameter range
WithinDateRange = _
dtmDataRangeStart <= dtmParamRangeEnd And _
dtmDataRangeEnd >= dtmParamRangeStart
End Function
So, if you have OccupantID, DateIn and DateOut columns in a table say, you should be able to count the number of distinct occupants within any date/time range with:
PARAMETERS
[Enter start date:] DATETIME,
[Enter end date:] DATETIME;
SELECT
[Enter start date:] AS DateFrom,
[Enter end date:] AS DateTo,
COUNT(*) AS OccupantsCount
FROM
(SELECT DISTINCT OccupantID
FROM YourTable
WHERE WithinDateRange([Enter start date:], [Enter end date:], DateIn, DateOut);
Ken Sheridan, Stafford, England