@Smitsky34
You can do this without having to create Number of Hours per record.
If I change my above button code to this
ClearCollect(
colBookings,
{
ID:1, Loc: "Canon City", Office: "Canon City Office", Vehicle: "TEST FOR MIKE",
StartDate: Date(2023,08,05), StartTime: TimeValue("10:00 AM"), EndDate: Date(2023,08,05), EndTime: TimeValue("1:00 PM")
//,NumHrs: Hour(TimeValue("1:00 PM")) - Hour(TimeValue("10:00 AM"))
},
{
ID:2, Loc: "Canon City 2", Office: "Canon City Office", Vehicle: "TEST FOR MIKE",
StartDate: Date(2023,08,05), StartTime: TimeValue("07:00 AM"), EndDate: Date(2023,08,05), EndTime: TimeValue("09:00 AM")
//,NumHrs: Hour(TimeValue("1:00 PM")) - Hour(TimeValue("10:00 AM"))
},
{
ID:3, Loc: "Canon City 3", Office: "Canon City Office", Vehicle: "TEST FOR BOB",
StartDate: Date(2023,08,05), StartTime: TimeValue("07:00 AM"), EndDate: Date(2023,08,05), EndTime: TimeValue("09:00 AM")
//,NumHrs: Hour(TimeValue("1:00 PM")) - Hour(TimeValue("10:00 AM"))
}
);
Clear(colMissingHrs);
ForAll(
Filter(colBookings, StartDate = dpBookingDate.SelectedDate, Vehicle = ddVehicle.Selected.Value) As _data,
ForAll(
Sequence( Hour(TimeValue(_data.EndTime)) - Hour( TimeValue(_data.StartTime))+1, 0, 1) As counter,
Collect(
colMissingHrs,
{Hour: Hour( _data.StartTime) + counter.Value}
)
)
)
I get three records, 2 for the van named "TEST FOR MIKE".
The above will error out at first until you do the following:
- add a DatePicker called dpBookingDate and
- add a dropdown called ddVehicle, with Items = Distinct(colBookings, Vehicle) <-- you'll need to possibly change this to Choices(ReservedTimes.Van)??
Now, select 5th Aug 2023 from the DatePicker and "TEST FOR MIKE".
The Hour selected should now only display the available hours.
Some adjustment will be needed for you situation but this gives you all the working parts - I think?