I have to filter data with respect to a field named CreatedDate having type datetime.

In input I'm just giving date (not time), I want to fetch all records with respect to specific date (ignoring time), I want to use CAML query to do this. How should I ignore time and search by just giving date as input.

Currently, I'm using this CAML query to search:

<Where><Eq><FieldRef Name='Created'/>
  <Value IncludeTimeValue='FALSE' Type='DateTime'>" + createdDate + "</Value></Eq></Where>
  • 1
    OMG, it worked perfectly :))
    – Isbah Khan
    May 18, 2016 at 6:43

2 Answers 2


Try this : ---> createdDate.ToString("s")

  • No problem. Come again:))
    – Goshky
    May 18, 2016 at 6:51
  • This works for me :) May 9, 2017 at 12:27

Please note that date you are passing in CAML query need to be in ISO8601DateTime format.

string createdDate = startDate.ToString("yyyy-MM-ddTHH:mm:ssZ");

then pass this in CAML query.

Reference: http://www.codeproject.com/Articles/414414/SharePoint-Working-with-Dates-in-CAML

  • actually i dont want to give time as i said in my question "i have to ignore time in my input".
    – Isbah Khan
    May 18, 2016 at 6:45
  • However; Goshy's answer worked for me : createdDate.ToString("s")
    – Isbah Khan
    May 18, 2016 at 6:45
  • 3
    Yeah. You can use above code even without passing time. You need to just pass formatted string in CAML query. Both answers are right. :) May 18, 2016 at 6:47

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.