CutAndPaste
Registered User.
- Local time
- Today, 23:48
- Joined
- Jul 16, 2001
- Messages
- 60
Actually, it's Property (as in Houses) rather than Rooms but as "Property" has another meaning in the Access context....
Here's what I've got (simplified version):
Properties Table
PropertyID (PK)
PropertyName
People Table
PersonID (PK)
PersonName
PersonCategory
Occupancy Table
OccupancyID (PK)
PersonID (FK)
PropertyID (FK)
OccupancyStartDate
OccupancyEndDate
A form with two unbound fields
ReportStartDate
ReportEndDate
Some business Rules:
A new occupancy for a property can't start on the same day as the previous occupancy ends (so days should not be "double counted")
For each Property:
Some Occupancies may start before ReportStartDate and end after ReportEndDate.
Some Occupancies may start after ReportStartDate and end after ReportEndDate.
Some Occupancies may start after ReportStartDate and end before ReportEndDate.
Any gaps between an OccupancyEndDate and an OccupancyStartDate need to be counted as "Voids".
For any reporting defined by period as defined by ReportStartDate and ReportEndDate, "Occupied Days" + "Voids" = "Number of days in period"
The important part in later reporting is to remove the "Void" days from the calculations as I want to get a measure of actual occupancy breakdown by PersonCategory for the days the Property was actually available, not the total of days between ReportStartDate and ReportEndDate.
I can write a query that calcualtes the durations of Occupancies for each property quite easily if they start and end between the ReportStartdate and the ReportEnddate (OccupancyEndDate - OccupancyStartDate). But how do I factor in an OccupancyStartDate before the ReportStartdate? I tried using an IIF statement but this wouldn't work, (though this may be my fault in the IIF construction).
Duration:IIf("(IsNull[OccupancyEndDate])","Now() - [StartDate]","[EndDate]-[StartDate]")
I want be able to count all of the days the property was occupied between the dates and get a count of the void dates. Can anyone point me in the right direction in terms of query design to get this going?
Simon
Here's what I've got (simplified version):
Properties Table
PropertyID (PK)
PropertyName
People Table
PersonID (PK)
PersonName
PersonCategory
Occupancy Table
OccupancyID (PK)
PersonID (FK)
PropertyID (FK)
OccupancyStartDate
OccupancyEndDate
A form with two unbound fields
ReportStartDate
ReportEndDate
Some business Rules:
A new occupancy for a property can't start on the same day as the previous occupancy ends (so days should not be "double counted")
For each Property:
Some Occupancies may start before ReportStartDate and end after ReportEndDate.
Some Occupancies may start after ReportStartDate and end after ReportEndDate.
Some Occupancies may start after ReportStartDate and end before ReportEndDate.
Any gaps between an OccupancyEndDate and an OccupancyStartDate need to be counted as "Voids".
For any reporting defined by period as defined by ReportStartDate and ReportEndDate, "Occupied Days" + "Voids" = "Number of days in period"
The important part in later reporting is to remove the "Void" days from the calculations as I want to get a measure of actual occupancy breakdown by PersonCategory for the days the Property was actually available, not the total of days between ReportStartDate and ReportEndDate.
I can write a query that calcualtes the durations of Occupancies for each property quite easily if they start and end between the ReportStartdate and the ReportEnddate (OccupancyEndDate - OccupancyStartDate). But how do I factor in an OccupancyStartDate before the ReportStartdate? I tried using an IIF statement but this wouldn't work, (though this may be my fault in the IIF construction).
Duration:IIf("(IsNull[OccupancyEndDate])","Now() - [StartDate]","[EndDate]-[StartDate]")
I want be able to count all of the days the property was occupied between the dates and get a count of the void dates. Can anyone point me in the right direction in terms of query design to get this going?
Simon