locked
CAML Query to display all Pages modified after 13 February 2011 RRS feed

  • Question

  • I am very new to CAML queries and am wanting to get a SharePoint Content and Structure Report to display all pages within a site collection that have been modified after 13 February 2011.

    I have:

    <Where><Gt><FieldRef Name="Modified"></FiedlRef><Value IncludeTimeValue="FALSE" Type="DateTime">13/02/2011</Value></Gt></Where>

    but it is not displaying any results.

    Please note we are using date/month/year for our modified date (New Zealand GMT time) and are using the built-in field/column for the modified date.

    Tuesday, May 31, 2011 4:28 AM

Answers

  • You're welcome, 

    1. Why would you like to change the field format directly ? Sharepoint doesn't display it as dd/mm/YYYY for you already ?

     

    2.

    Is that what you search :

    <Where><Eq><FieldRef Name='FileExtension'><Value Type='string'>aspx</Value></FieldRef></Eq></Where>

     

    Regards,


    Jeff ANGAMA. Sharepoint Consultant Blog : http://jeff-sharepoint-note.blogspot.com/
    • Edited by Jeff ANGAMA Wednesday, June 1, 2011 8:42 AM Edit 1.
    • Marked as answer by WDC Online Wednesday, June 1, 2011 11:29 PM
    Wednesday, June 1, 2011 7:39 AM

All replies

  • Hello,

     

    Do you use U2U Caml builder to generate your caml query ?

    I've just tried as you asked and I got that code : 

     

    <Where>

    <Gt>

    <FieldRef Name="Modified" /><Value IncludeTimeValue="TRUE" Type="DateTime">2011-04-25T14:10:12Z</Value>

    </Gt>

    </Where>

     

    I'm also using the same date pattern (date/month/year) in my site. So try to modify your request as 2011-02-13.

    It should work

     


    Jeff ANGAMA. Sharepoint Consultant Blog : http://jeff-sharepoint-note.blogspot.com/

     

    • Proposed as answer by Jeff ANGAMA Tuesday, May 31, 2011 10:13 AM
    • Unproposed as answer by Mike Walsh FIN Tuesday, May 31, 2011 5:06 PM
    • Edited by Mike Walsh FIN Tuesday, May 31, 2011 5:08 PM Moderator Note added on not proposing own posts.
    • Edited by Jeff ANGAMA Wednesday, June 1, 2011 7:39 AM Ok I didn't know. sorry :)
    Tuesday, May 31, 2011 10:13 AM
  • Hi Instar,

     

    I understand that you write the CAML Query but it doesn’t display any results. It is because when it comes to CAML, the date/time format is "yyyy-mm-ddThh:mm:ss".Here are my suggestions:

    1.       Change the format of the modified column to yyyy-mm-dd.

    2.        Try this way :

      <Where>

           <Geq>

                <FieldRef Name="Modified" />

                <Value Type="DateTime">

                    <Today OffsetDays="-107" />

                </Value>

            </Geq>

    </Where>

    -107 means that 2011.2.13 is 107 days away from today .

     

    For more information ,please refer to these sites:

    CAML Query – DateTime: http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/fed59f8e-72e2-46e2-9329-460fd65d7536/

    Writing CAML Queries For Retrieving List Items from a SharePoint List: http://sharepointmagazine.net/articles/writing-caml-queries-for-retrieving-list-items-from-a-sharepoint-list

    CAML query on DateTime field : http://www.eggheadcafe.com/software/aspnet/30787023/caml-query-on-datetime-field-bug.aspx

     

    If you have any more questions ,please feel free to ask .

     

    Thanks,


    Regards, Rock Wang Microsoft Online Community Support
    Tuesday, May 31, 2011 11:22 AM
  • Thanks Jeff.  We do have the U2U CAML builder but I can't get the builder to work.
    Tuesday, May 31, 2011 8:24 PM
  • Thank you Rock Wang. 

    1.  I do not know how to change the 'Modified' column as I can't seem to find it in the Site Columns list.  This is the built-in column so unsure where / how to find it and change the format.

    2. That CAML query worked but it is displaying everything that has been modified.  I just need to see the .aspx pages that have been modified.  Is there a way to filter the query just to display .aspx pages?

    Regards


    Tuesday, May 31, 2011 9:20 PM
  • You're welcome, 

    1. Why would you like to change the field format directly ? Sharepoint doesn't display it as dd/mm/YYYY for you already ?

     

    2.

    Is that what you search :

    <Where><Eq><FieldRef Name='FileExtension'><Value Type='string'>aspx</Value></FieldRef></Eq></Where>

     

    Regards,


    Jeff ANGAMA. Sharepoint Consultant Blog : http://jeff-sharepoint-note.blogspot.com/
    • Edited by Jeff ANGAMA Wednesday, June 1, 2011 8:42 AM Edit 1.
    • Marked as answer by WDC Online Wednesday, June 1, 2011 11:29 PM
    Wednesday, June 1, 2011 7:39 AM
  • You're welcome, 

    1. Why would you like to change the field format directly ? Sharepoint doesn't display it as dd/mm/YYYY for you already ?

     

    2.

    Is that what you search :

    <Where><Eq><FieldRef Name='FileExtension'><Value Type='string'>aspx</Value></FieldRef></Eq></Where>

     

    Regards,


    Jeff ANGAMA. Sharepoint Consultant Blog : http://jeff-sharepoint-note.blogspot.com/

    Thanks Jeff.

    Re number 1 above:  Sorry I must of misunderstoof your previous reply saying that the modified column needed to be changed.  I thought you meant that I had to format that column back to yyyy/mm/dd. 

    We did not reformat this column in the first instance. We just changed the regional settings within the site collection and on central admin, and it automatically formatted to dd/mm/yyyy.

    Thank you for the CAML query to find all .aspx pages.  Unfortunately I could not get the CAML query to work.

     <Where>
     <And>
      <Geq>
      <FieldRef Name="Modified" />
      <Value Type="DateTime"><Today OffsetDays="-60" /></Value>
      </Geq>
      <Eq>
      <FieldRef Name=”FileExtension” />
      <Value Type='string'>aspx</Value>
      </Eq>
     </And>
    </Where>

    Regards

    Wednesday, June 1, 2011 11:29 PM