0

This question is an exact duplicate of:

HI am trying to use CAML query to pull the data of list based on date range and I am unable to pull the data with the query i am using. I have column name as 'created' and which is for both fromDate and toDate where the dates are used . My date format is "Wed May 6 16:40:23 EDT 2015" My query part Am trying is this. how to get my date range work. can someone help me out with this.

camlQuery.set_viewXml('<View><Query><Where><And><And><Neq><FieldRef Name="ID" /><Value Type="Number">0</Value></Neq><FieldRef Name="_ModerationStatus" /><Value Type="ModStat">0</Value></Eq></And><Eq><Geq><FieldRef Name="Created" /><Value IncludeTimeValue="FALSE" Type="DateTime">" + Iso8601toDate + "</Value></Geq><Leq><FieldRef Name="Created" /><Value IncludeTimeValue="FALSE" Type="DateTime">"+ Iso8601fromDate +" </Value></Leq></And></Where><OrderBy><FieldRef Name="_ModerationStatus" Ascending="True" /></OrderBy></Query></View>');

marked as duplicate by Robert Lindgren Jul 10 '15 at 11:12

This question was marked as an exact duplicate of an existing question.

  • 1
    You should use an ISO format date string I think! – Robert Lindgren May 7 '15 at 14:57
  • but when i am trying to see the same on U2U builder it shows me 2015-05-07T06:59:44Z – SPLearner May 7 '15 at 15:03
  • And that is exactly what I refer to above (an ISO formatted date string) – Robert Lindgren May 7 '15 at 15:22
  • Hi robert , I have modified the query can you see if its the right way? – SPLearner May 7 '15 at 15:28
0

I think you have mentioned exact similar question with similar CAML query here at SharePoint Stack Exchange.

Refer below updated query from U2U builder

<View>
<Query>
<Where>
    <And>
        <Neq>
            <FieldRef Name="ID" />
            <Value Type="Number">0</Value>
        </Neq>
        <And>
            <Eq>
                <FieldRef Name="_ModerationStatus" />
                <Value Type="ModStat">0</Value>
            </Eq>
            <And>
                <Geq>
                    <FieldRef Name="Created" />
                    <Value Type="DateTime">' + fromDate + '</Value>
                </Geq>
                <Leq>
                    <FieldRef Name="Created" />
                    <Value Type="DateTime">' + toDate + '</Value>
                </Leq>
            </And>
        </And>
    </And>
</Where>
<OrderBy><FieldRef Name="_ModerationStatus" Ascending="True" /></OrderBy>
</Query>

I hope that helps!!

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