Search code examples
sharepointsharepoint-2007windows-sharepoint-services

SharePoint via web services: how to pass a date?


Trying to pass a date to an add item with the Lists web service using:

string item = "<Method ID=\"1\" Cmd=\"New\">" +
                  @"<Field Name=""AcceptanceTime"">" + DateTime.Now + "</Field>"

But it's generating an exception:

0x8102001c Invalid date/time value
A date/time field contains invalid data. Please check the value and try again.

Any idea how to pass a date here successfully?


Solution

  • Sharepoint requires the date in the following format....

    YourDateTime.ToString("yyyy-MM-ddTHH:mm:ssZ")