0

I am trying to get the data based on some datetime string using CAML query.

Here is my CAML query:

<View>
    <Query>
        <Where>
            <And>
                <Le>
                    <FieldRef Name='StartDateTime'/>
                    <Value Type='DateTime' IncludeTimeValue='TRUE'>2017-03-23T05:20:00.000Z</Value>
                </Le>
                <Ge>
                    <FieldRef Name='EndDateTime'/>
                    <Value Type='DateTime' IncludeTimeValue='TRUE'>2017-03-23T05:20:00.000Z</Value>
                </Ge>
            </And>
        </Where>
    </Query>
</View>

When I am passing the value of date-time in ISO string it gives me error "500 (Internal Server Error)"

If I pass date without converting to ISO string it gives no result.

I am using SharePoint Online, my current timezone in regional setting is set to India.

4

It works for my list. You just check the internal name of the fields StartDateTime and EndDateTime and date format mention in the value section in query 2017-03-23T12:00:00Z

I think you mention Le instead of Lt(less than)/Leq(less than or equal) and Ge instead of Gt(greater than)/Geq(greater than or equal) and . in this 2017-03-23T05:20:00.000Z

see below my example.

<View>  
    <Query> 
        <Where>
            <And>
                <Lt>
                    <FieldRef Name='StartDateTime' />
                    <Value Type='DateTime' IncludeTimeValue='TRUE'>2017-03-23T12:00:00Z</Value>
                </Lt>
                <Gt>
                    <FieldRef Name='EndDateTime' />
                    <Value Type='DateTime' IncludeTimeValue='TRUE'>2017-03-23T12:00:00Z</Value>
                </Gt>
            </And>
        </Where> 
    </Query> 
    <ViewFields>
        <FieldRef Name='StartDateTime' />
        <FieldRef Name='EndDateTime' />
    </ViewFields> 
</View>
4

The operators "Le" & "Ge" are not valid. It needs to either "Lt"/"Gt" (Less than/Greater than) OR "Leq"/"Geq" (Less than or Equal/Greater than or equal").

Also, it may be that, one would use "Geq"/"Gt" with Start Date and "Leq"/"Lt" with End date.

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.