3

I am wanted to query a list which brings back items which are greater than 2 days old. I am unsure how the CAML query should look. Below is my code

<Where>
    <And>
      <Eq>
        <FieldRef Name="Status"/>
        <Value Type="Choice">NEW</Value>
      </Eq>
      <Eq>
        <FieldRef Name="Created"/>
        <Value Type="DateTime">
              what goes here
        </Value>
      </Eq>
    </And>
5

You'll want to use the Greater than or Equal operator (Geq) and then use the Today element for relative comparison:

<Where>
    <And>
      <Eq>
        <FieldRef Name="Status"/>
        <Value Type="Choice">NEW</Value>
      </Eq>
      <Geq>
        <FieldRef Name="Created"/>
        <Value Type="DateTime"><Today OffsetDays="-2" /></Value>
      </Geq>
    </And>
</Where>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.