Hi Dojo,
I'm trying to select all reservations in an automation script as indicated in the image marked in green containing a specific resource. This is the algorithm that I'm using but I'm not getting any results. We are unsure about the formatting, could anyone help us out? (We already tried using a NOT(expression) but this gives compile errors)
var filter = ReservationInstanceExposers.ResourceIDsInReservationInstance
.Contains(neededResource.ID)
.AND(ReservationInstanceExposers.Status.NotEqual((int)ReservationStatus.Canceled))
.AND(ReservationInstanceExposers.Status.NotEqual((int)ReservationStatus.Ended))
.AND(ReservationInstanceExposers.Start.GreaterThanOrEqual(start).OR(ReservationInstanceExposers.End.GreaterThanOrEqual(start)))
.AND(ReservationInstanceExposers.Start.LessThanOrEqual(stop).OR(ReservationInstanceExposers.End.LessThanOrEqual(stop)));var instances = SrmManagers.ResourceManager.GetReservationInstances(filter);
I'm guessing from your image you want to retrieve all bookings that have overlap with a certain time range. For that, I believe you can simplify your query to use 2 conditions:
ReservationInstanceExposers.Start.LessThanOrEqual(stop).AND(ReservationInstanceExposers.End.GreaterThanOrEqual(start))
A more detailed answer on StackOverflow.
The rest of your query looks good though.
Thanks Sebastiaan, This works but only if I convert my datetimes to ToUniversalTime