Dates incorrectly formatted


I believe the dates are not being correctly formatted to work for all cultures by CAML.Net (there not working for me with en-nz culture) - I think perhaps the correct behaviour would be to have the date output in ISO8601 format by the CAML.Value(DateTime dt) method using code like this (which comes from U2U Caml Query Builder):
private static string CreateISO8601DateTimeFromSystemDateTime(DateTime date)
return string.Format(CultureInfo.InvariantCulture, date.ToString("yyyy-MM-ddThh:mm:ssZ"), new object[0]);
I'm having to use this function at the moment in combination with the 2 parameter overload of CAML.Value i.e. CAML.Value("DateTime", CreateISO8601DateTimeFromSystemDateTime(date)) to get reliable query results, but it would be nice to get this as the default behavior.
  • Alex


Prabhash wrote Dec 9, 2008 at 3:59 PM

Ya I also have the same problem. Thanks Alex for posting a workaround here. I really did not notice that value method has a 2 paramater overload.

Prabhash wrote Dec 9, 2008 at 4:01 PM

Just noticed that we can also use SPUtility.CreateDateTimeFromISO8601DateTimeString built in utility method for this.

jholliday wrote Jan 16, 2009 at 3:35 PM

Thanks, Alex. I'll add this function to the next version.

wrote Feb 14, 2013 at 2:26 AM

wrote Mar 25, 2014 at 12:30 PM