Wednesday, August 19, 2009

Using dates in CAML

Your just need to use this in correct format:yyyy-mm-ddThh:mm:ss
To get this format in c# use:
SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Today).
Now you can use it:
string StartDateForCaml = SPUtility.CreateISO8601DateTimeFromSystemDateTime(StartDate);
spQuery.Query ="<Where><Eq><fieldref name="StartDate"><value type="DateTime">StartDateForCaml </value ></Eq></Where>";

No comments:

Post a Comment