Monday, 26 March 2012

Caml query compare between date range from today in sharepoint 2010 (SP 2010) and

How to calculate date from the list items using caml  query and compare date range between from today in sharepoint 2010 (SP 2010):

For my scenario, My start should lbe less than today and expiry date should be greater than today date and list items should be displayed based on priority order column( ascending or descending order.). The date format should not be empty or null.

This caml query also check for boolean status whether it is active or not. (true or false)

We can use caml query builder to check this whether it is working or not.


Caml Query:

Using the SP2010 Client Object Model to update a list item

    <Where> 
      <And> 
        <And> 
           
            <Leq> 
              <FieldRef Name='StartDate' /> 
              <Value Type='DateTime' IncludeTimeValue='False'> 
                <Today /> 
              </Value> 
            </Leq> 
            <IsNotNull> 
              <FieldRef Name='StartDate' /> 
            </IsNotNull> 
          
           
            <Gt> 
              <FieldRef Name='EndDate' /> 
              <Value Type='DateTime' IncludeTimeValue='False'> 
                <Today /> 
              </Value> 
            </Gt> 
            <IsNotNull> 
              <FieldRef Name='EndDate' /> 
            </IsNotNull> 
          
        </And> 
        <Eq> 
          <FieldRef Name='Active' /> 
          <Value Type='Boolean'>1</Value> 
        </Eq> 
      </And> 
    </Where> 
    <OrderBy> 
      <FieldRef Name='EndDate' Ascending='True' /> 
    </OrderBy> 


1 comment:

  1. you identified the combination of Geq and Leq properly ..

    ReplyDelete