I want to calculate an occupancy rate for nights stayed in a hotel. The occupancy rate needs to be for a calendar year.
The fields I am working with are
Arrival
Departure
I have parameters set up in the query as criteria on the Departure field.
FromDate
ToDate
Most of the arrival dates AND departure dates fall within the year...but the reservation occupying the hotel room on January 1 and on December 31 do not start/stop on those exact dates.
For example, someone stayed from December 25 through January 5...I only want 4 of those nights in that year's count (January 1, 2, 3, 4--checkout is on the 5th, they didn't stay that night). My query would count 11.
This is what I'm running in my query, which is beautiful except for the first and last reservation of the year.
Nights: DateDiff("d",[Arrival],[Departure])
parameters Between [FromDate] and [ToDate] which I have set as criteria on the Departure field (and that would be Jan 1 and Dec 31 of any year).
I know how to get what I want...but I don't know how to write it in the query or in code (OMG VBA---I'm just not there. LOL!)
If the Arrival is before (less than?) FromDate, then I need to calculate that entry Between FromDate and Departure (not between Arrival and Departure).
ALSO
If the Departure is after (greater than?) ToDate, then I need to calculate that entry Between Arrival and ToDate (not between Arrival and Departure).
All the other entries are good.
Who out there is smarter than me? :-)
The fields I am working with are
Arrival
Departure
I have parameters set up in the query as criteria on the Departure field.
FromDate
ToDate
Most of the arrival dates AND departure dates fall within the year...but the reservation occupying the hotel room on January 1 and on December 31 do not start/stop on those exact dates.
For example, someone stayed from December 25 through January 5...I only want 4 of those nights in that year's count (January 1, 2, 3, 4--checkout is on the 5th, they didn't stay that night). My query would count 11.
This is what I'm running in my query, which is beautiful except for the first and last reservation of the year.
Nights: DateDiff("d",[Arrival],[Departure])
parameters Between [FromDate] and [ToDate] which I have set as criteria on the Departure field (and that would be Jan 1 and Dec 31 of any year).
I know how to get what I want...but I don't know how to write it in the query or in code (OMG VBA---I'm just not there. LOL!)
If the Arrival is before (less than?) FromDate, then I need to calculate that entry Between FromDate and Departure (not between Arrival and Departure).
ALSO
If the Departure is after (greater than?) ToDate, then I need to calculate that entry Between Arrival and ToDate (not between Arrival and Departure).
All the other entries are good.
Who out there is smarter than me? :-)
Comment