I have a list with leave requests which a start and end date. I want to check for a leave request if the dates between starting date and ending date of the leave request . already exist in a calendar. I do that with CAML Query.
Here is my caml :
CamlQuery getHolidaysQuery = new CamlQuery();
getHolidaysQuery.ViewXml =
@"<View>
<Query>
<Where>
<And>
<Geq>
<FieldRef Name='EventDate' />
<Value IncludeTimeValue='FALSE' Type = 'DateTime'>" + currentDate. + @" </Value>
</Geq>
<Leq>
<FieldRef Name='EndDate' />
<Value IncludeTimeValue='FALSE' Type = 'DateTime'>" + currentDate + @" </Value>
</Leg>
</And>
</Where>
</Query>
</View>";
ListItemCollection getHolidaysItems = holidaysCalendar.GetItems(getHolidaysQuery);
clientContext.Load(getHolidaysItems);
clientContext.ExecuteQuery();
It always returns Count = 0 which means it didn't find any items on the calendar. I 've created before an item in calendar so that the CAML Query should return something more than 0.
If anyone could share his wisdom on this i would be grateful.
Thanks