Nick Grattan’s SharePoint Blog

About Microsoft SharePoint and some .NET

WSS 3.0 Web Services – How To Update Date/Time Values

with 2 comments

When adding or updating list items using the WSS Web Service ‘UpdateListItems’ method you need to pass data / time values as strings. The format should be passed in the form ‘yyyy-mm-ddThh:mm:ssZ”.

This specifies a ISO date/time format with time zone information. The “Z” indicates that the time is in “Coordinated Universal Time” (UTC).

The “ToString” method for a DateTime object (e.g. “dt” below) can be used to format a date/time using this format by passing the “u” format descriptor:

String s = dt.ToString(“u”);

Note that the DateTime object must first be converted from local time to UTC. The DateTime “ToUniversalTime” method will do this.

 

Written by Nick Grattan

February 22, 2008 at 11:20 am

2 Responses

Subscribe to comments with RSS.

  1. [...] WSS 3.0 Web Services – How To Update Date/Time Values [...]

  2. We are utilizing the Sharepoint Web Services to Add and Update SP Lists but are getting wierd results in that the ‘Stored’ Value on the DB is 1 hour different than the Date Value passed in.

    The SP Site is going to be used by many people in different Timezones so my questions are:

    - what timezone should the SP regional seetings be set to? GMT / GMT – 5, etc
    - does the the date being ‘passed’ in have to be converted to utc first?

    ex. I want to pass in 8:00 AM EDT, to be displayed in a SP List.

    Thanks

    Andrew E. Kirin

    Andrew E. kirin

    September 17, 2008 at 7:27 pm


Leave a Reply