Monday, 1 November 2010

Using CAML and SPQuery to query using dates

Problem: Using SPQuery I can't filter using a datatime parameter.Hypothesis: I can see my custom web part code is formatting the DateTime selection (SharePoint:DateTimeControl) differently in my custom code CAML than the CAML generated by U2U.Resolution:
Use the Microsoft.SharePoint.Utilities.SPUtility.CreateISO8601DateTimeFromSystemDateTime() method to get your DateTime control value into the correct format.SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.UtcNow)