Unable to get the pages which have their calcualted date.time field equal today using CAML
-
08-02-2021 - |
Question
I am working on an online SharePoint site collection, where I have a calculated column named "ExpiryDate" of type Datetime, and I want to get all the pages which have their expiry date equal today, i tried the following CAML query , but it did not return any pages:
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View><Query><Where><Eq><FieldRef Name ='ExpiryDate'/><Value Type='DateTime'>Today/></Value></Eq></Where></Query><RowLimit>3000</RowLimit></View>";
Any idea why my query is not working?
La solution
I can see there is a syntax error in your code near <Today/>
. Use it like below:
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View><Query><Where><Eq><FieldRef Name ='ExpiryDate'/><Value Type='DateTime'><Today/></Value></Eq></Where></Query><RowLimit>3000</RowLimit></View>";
If that does not work then try using:
<Query><Where><Eq><FieldRef Name="ExpiryDate" /><Value Type="Calculated"><Today/></Value></Eq></Where></Query>
Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange