CAML Query for calender list

Standard

To get all events in current month:

<Where>
    <DateRangesOverlap>
        <FieldRef Name="EventDate" />
        <FieldRef Name="EndDate" />
        <FieldRef Name="RecurrenceID" />
        <Value Type="DateTime"><Month /></Value>
    </DateRangesOverlap>
</Where>

To get all todays events:

string PreviousDay = DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd") ;
string NextDay = DateTime.Today.AddDays(1).ToString("yyyy-MM-dd");
string query =
@"<Where>
    <And>
      <Gt>
        <FieldRef Name='EventDate' />
        <Value IncludeTimeValue='FALSE' Type='DateTime'>" + PreviousDay  + "</Value>
      </Gt>
      <Lt>
         <FieldRef Name='EventDate' />
         <Value IncludeTimeValue='FALSE' Type='DateTime'>" + NextDay  + "</Value>
       </Lt>
     </And>
</Where>";
Advertisements