Unable to get the pages which have their calcualted date.time field equal today using CAML
-
08-02-2021 - |
Pergunta
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?
Solução
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>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange