views:

136

answers:

1

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?

+1  A: 

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

YourDateTime.ToString("yyyy-MM-ddTHH:mm:ssZ")
JL
This format is ISO 8601 (http://en.wikipedia.org/wiki/ISO_8601). You can also use a utility function to do this: SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Now)
Kit Menke