1

I have the following CAML:

<Where>
    <And>
        <Eq>
            <FieldRef Name='Author' LookupId='TRUE' />
            <Value Type='User'>473</Value>
        </Eq>
        <Eq>
            <FieldRef Name='Datum' />
            <Value Type='DateTime'>2015-06-05T00:00:00Z</Value>
        </Eq>
    </And>
</Where>

In my list I have 8 items, 7 of these have Author equals 473 and 2 of these have Datum equals 2015-06-05. Whatever value I pass to the Datum i always get 7 items. What is wrong?

  • Are you certain that Datum is the internal name of the column? Otherwise it looks correct. – Eric Alexander Jun 5 '15 at 14:35
  • Yes it is... shouldn't thorw it an exception otherwise? – Emaborsa Jun 5 '15 at 14:42
  • try this one <Value IncludeTimeValue='TRUE' Type='DateTime'>2015-06-05T00:00:00</Value> – Waqas Sarwar MVP Jun 5 '15 at 14:49
  • Nope. The curious thing is that I get 7 items....if the passed date value isn't correct, I should get 0 items. Right? – Emaborsa Jun 5 '15 at 14:51
  • It tends to ignore the CAML if the field values aren't correct rather than throwing any error. I'd try downloading the BIWUG CAML Designer and see what it spits out after constructing the query. biwug.be/resources – Eric Alexander Jun 5 '15 at 15:00
1

I wasn't able to find out the problem, but with the following workaround I got it:

<Where>
<And>
    <Eq>
        <FieldRef Name='Author' LookupId='TRUE' />
        <Value Type='User'>473</Value>
    </Eq>
    <And>
        <Leq>
            <FieldRef Name='Datum' />
            <Value Type='DateTime'>2015-06-05 00:00:00</Value>
        </Leq>
        <Geq>
            <FieldRef Name='Datum' />
            <Value Type='DateTime'>2015-06-05 00:00:00</Value>
        </Geq>
    </And>
</And>

0

Please check the time zone of your server. It is possible that your web time zone and browser time zone differs. You should try these options:

  1. Set property SP.CamlQuery.datesInUtc to false
  2. Set property SP.CamlQuery.datesInUtc to true and pass correct value in UTC. For example, if your web time zone is +2 UTC, browser shows date value 2015-06-05 00:00:00, but real value in SharePoint database is 2015-06-04 22:00:00

Play with this settings and values.

  • I tryied it out, but the result does not change. – Emaborsa Jun 8 '15 at 6:18

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.