1

I wrote this caml query to get the data. the query i wrote-

<View>
<Query>
    <Where>
    <And>
    <Eq>
        <FieldRef Name='AccNo' />
        <Value Type='Text'>0258</Value>
    </Eq>
    <Eq>
        <FieldRef Name='EmpInTime' />
        <Value Type='DateTime' IncludeTimeValue='FALSE'>2017-02-23 00:00:00</Value>
    </Eq>
    </And>
    </Where>
</Query>
</View>

this should return only one row. but it returns more. what is the problem with this query?

Update: Tried "2017-02-23 T00:00:00Z" too as the DateTime value.

6
  • can you try using it as 2017-02-23 T00:00:00Z ? Feb 23, 2017 at 9:29
  • try this but doesnot work Feb 23, 2017 at 9:33
  • Please try to pass ISO8601DateTime in CAML query like SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Now);. Feb 23, 2017 at 9:36
  • 2
    2017-02-23T12:00:00Z should work fine. Make sure there are no spaces and if the column doesn't include time value, it is 12:00:00 by default, not 00:00:00 :)
    – Gintas K
    Feb 23, 2017 at 9:53
  • 1
    Also, using <eq> with DateTime values is not recommended, better use other comparissons like <leq>,<geq>, etc.
    – Gintas K
    Feb 23, 2017 at 9:56

2 Answers 2

1

Finally it works

the query is:

<View>
 <Query>
  <Where>
   <And>
    <Eq>
     <FieldRef Name='AccNo' />
     <Value Type='Text'>0258</Value>
   </Eq>
    <Geq>
     <FieldRef Name='EmpInTime' />
     <Value Type='DateTime' IncludeTimeValue='True'>2017-02-23T12:00:00Z</Value>
    </Geq>
    <Leq>
     <FieldRef Name='EmpInTime' />
     <Value Type='DateTime' IncludeTimeValue='True'>2017-02-24T12:00:00Z</Value>
    </Leq>
  </And>
 </Where>
</Query>
</View>

Change the time with 2017-02-23T12:00:00Z and use Geq and Leq in stead of Eq.

-1

try below just updated

<View>
 <Query>
  <Where>
   <And>
    <Eq>
     <FieldRef Name='AccNo' />
     <Value Type='Text'>0258</Value>
   </Eq>
    <Eq>
     <FieldRef Name='EmpInTime' />
     <Value Type='DateTime' IncludeTimeValue='True'>2017-02-23T00:00:00Z</Value>
    </Eq>
  </And>
 </Where>
</Query>
</View>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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