I need to get the list item created on a particular date. The below caml query doesn't seem to work. It always retuns 0

 query.ViewXml = @"<View><Query><Where><Eq><FieldRef Name='Created'/><Value Type='DateTime' IncludeTimeValue='false'>"+ date +"</Value></Eq></Where></Query></view>";

is there anything wrong in the query?

  • provide the 'date' return type used in query Commented Apr 18, 2016 at 11:24
  • Hi @DikeshGandhi the date is 4/18/2016 12:00:00 AM
    – Obiliraj
    Commented Apr 18, 2016 at 11:27
  • I added the answer with SPUtility.CreateISO8601DateTimeFromSystemDateTime . If you need more info, please past your code. Commented Apr 18, 2016 at 12:12

1 Answer 1


You need to format the date like this:

Server Site

string date = SPUtility.CreateISO8601DateTimeFromSystemDateTime(inputDate);

Sample for your case:

inputDate = new DateTime(2016,04,18);
string date =  SPUtility.CreateISO8601DateTimeFromSystemDateTime(inputDate);

Client Side (client object model)

string date = inputDate.ToString("yyyy-MM-ddTHH:mm:ssZ");
  • 1
    Thanks @jpussacq . I'm not sure if this will work on CSOM. but the below worked query.ViewXml = "<View><Query><Where><Eq><FieldRef Name='Created' /><Value Type='DateTime' IncludeTimeValue='FALSE' >"+date.ToString("yyyy-MM-ddTHH:mm:ssZ")+"</Value></Eq></Where></Query></view>"; Looks like the sputility method too does the same
    – Obiliraj
    Commented Apr 18, 2016 at 13:22
  • Yes sorry. I had not realized it was CSOM Commented Apr 18, 2016 at 13:28
  • Updated my answer! Commented Apr 18, 2016 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.