Are you looking for the SharePoint 2013 Beta series, go to http://sharepoint2013beta.com/.

Convert DateTime to ISO8601 for use in SharePoint CAML queries

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.

Like this? Share the love:

Tags: , ,

Post Author

This post was written by who has written 314 posts on Furuknap's SharePoint Corner.

No comments yet.

Leave a Reply

  • RSS
  • Facebook
  • Twitter