CAML Query to display all Pages modified after 13 February 2011
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.
May 31st, 2011 12:32am
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/
Free Windows Admin Tool Kit Click here and download it now
May 31st, 2011 6:13am
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/
Moderator Note: NEVER propose your own posts as answers. The function is there so that people can propose the good answers of other people. It is NOT there for self-proposing.
May 31st, 2011 6:13am
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 workJeff ANGAMA. Sharepoint Consultant Blog : http://jeff-sharepoint-note.blogspot.com/
Free Windows Admin Tool Kit Click here and download it now
May 31st, 2011 6:15am
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
May 31st, 2011 7:25am
Thanks Jeff. We do have the U2U CAML builder but I can't get the builder to work.
Free Windows Admin Tool Kit Click here and download it now
May 31st, 2011 4:27pm
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
May 31st, 2011 5:23pm
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/
Free Windows Admin Tool Kit Click here and download it now
June 1st, 2011 3:39am
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
June 1st, 2011 7:31pm