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?

Était-ce utile?

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
scroll top