So, a colleague asked me about what format dates should be put into the where clause of a CAML query as. I’d had a lot of problems finding this out myself, and ultimately I found that a .ToString(“u”) on a DateTime object did the trick. The produces a time of the form 2006-04-17 21:29:09Z
For example, using a StringBuilder to create my CAML query (for my SPQuery object), this might look like:
caml.Append("<Leq>");
caml.Append("<FieldRef Name='MyDueDate'/>");
caml.Append("<Value Type='DateTime'>");
caml.Append(System.DateTime.Today.ToString("u"));
caml.Append("</Value>");
caml.Append("</Leq>");
(This query contains the date contained in the MyDueDate column with the current date and time).