Ever wanted to create a CML query and insert a DateTime value? No such luck, DateTime values cannot be inserted directly, you need to convert the DateTime value to ISO8601 format and there is no DateTime function to do that.
Luckily, SharePoint provides a function for you in a utility class. The function is called, descriptively enough, CreateISO8601DateTimeFromSystemDateTime.
Have a look:
DateTime dt = DateTime.Now;string date = Microsoft.SharePoint.Utilities.SPUtility.CreateISO8601DateTimeFromSystemDateTime(dt);
Now you can insert your date string into CAML and go on to conquer the world.

