2

For example, I reservation on 6/10/2016 - 8/10/2016. When I search start date on 7/10/2016 and end date is 7/10/2016 it do not show anything. if I use

<Query>
  <Where>
    <And>
     <Gt>
        <FieldRef Name='EndDate' />
        <Value IncludeTimeValue='TRUE' Type='DateTime'>2016-10-07T18:37:21Z</Value>
     </Gt>
     <Lt>
        <FieldRef Name='EventDate' />
        <Value IncludeTimeValue='TRUE' Type='DateTime'>2016-10-07T18:37:24Z</Value>
     </Lt>
  </And>
 </Where>
</Query>

It show every rows that pass 7/10/2016 too. I want to only show 6//10/2016 - 8/10/2016.How to fix this.

1
  • If you are agreed to any answer then you can accept / mark as useful :) Hope below answer is helpful.
    – Ram
    Sep 29 '17 at 7:22
2

You have to mention the Less than and Equal and Greater than Equal.

Instead of use and use Then you can get the proper result as you expected.

Please click here for reference.

Also this question is repeated.

1

Use <Geq> & <Leq> instead of <Gt> & <Lt> opearator in caml query

<Query>
  <Where>
    <And>
     <Geq>
        <FieldRef Name='EndDate' />
        <Value IncludeTimeValue='TRUE' Type='DateTime'>2016-10-07T18:37:21Z</Value>
     </Geq>
     <Leq>
        <FieldRef Name='EventDate' />
        <Value IncludeTimeValue='TRUE' Type='DateTime'>2016-10-07T18:37:24Z</Value>
     </Leq>
  </And>
 </Where>
</Query>

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.