locked
DateTime Fields for UpdateListItems not interpreted as UTC RRS feed

  • Question

  • Hello,

    I am attempting to use the UpdateListItems web service to add a new event to a calendar. I format the EventDate field according to the ISO8601 format, in UTC time. However, sharepoint interprets the time as a local time. This is especially problematic, because my server is in a different time-zone.

    How can I get it to interpret the datetime string correctly? Is this a bug in Sharepoint?

    My request XML looks like this:

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlnsTongue Tiedoap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body>
        <UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
          <listName>{C3D314D7-878D-4166-9F43-98BC1E0C5158}</listName>
          <updates>
            <Batch OnError="Return">
              <Method ID="1" Cmd="New" xmlns="http://schemas.microsoft.com/sharepoint/soap/">
                <Field Name="ID">99999</Field>
                <Field Name="Title">Title</Field>
                <Field Name="Description">Description</Field>
                <Field Name="EventDate">2008-07-02T16:42:52Z</Field>
              </Method>
            </Batch>
          </updates>
        </UpdateListItems>
      </soap:Body>
    </soap:Envelope>



    Wednesday, July 2, 2008 4:59 PM

Answers

  • Yes I can reproduce this...However, I have found the solution. The Batch element, apparently, accepts a DateInUtc attribute, which can cause the server to interpret the strings as UTC. There is absolutely no documentation to indicate that this is possible, but it works. Go figure...

     

    I guess you can file this as a documentation bug.

     

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlnsoap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body>
        <UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
          <listName>{C3D314D7-878D-4166-9F43-98BC1E0C5158}</listName>
          <updates>
            <Batch OnError="Return" DateInUtc="True">
              <Method ID="1" Cmd="New" xmlns="http://schemas.microsoft.com/sharepoint/soap/">
                <Field Name="ID">99999</Field>
                <Field Name="Title">Title</Field>
                <Field Name="Description">Description</Field>
                <Field Name="EventDate">2008-07-02T16:42:52Z</Field>
              </Method>
            </Batch>
          </updates>
        </UpdateListItems>
      </soap:Body>
    </soap:Envelope>

     

     

     

     

     

    Thursday, July 10, 2008 5:09 PM

All replies

  • Can you reproduce this?

     

    Does this happen for Update as well as New?

    Tuesday, July 8, 2008 5:13 PM
  • Yes I can reproduce this...However, I have found the solution. The Batch element, apparently, accepts a DateInUtc attribute, which can cause the server to interpret the strings as UTC. There is absolutely no documentation to indicate that this is possible, but it works. Go figure...

     

    I guess you can file this as a documentation bug.

     

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlnsoap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body>
        <UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
          <listName>{C3D314D7-878D-4166-9F43-98BC1E0C5158}</listName>
          <updates>
            <Batch OnError="Return" DateInUtc="True">
              <Method ID="1" Cmd="New" xmlns="http://schemas.microsoft.com/sharepoint/soap/">
                <Field Name="ID">99999</Field>
                <Field Name="Title">Title</Field>
                <Field Name="Description">Description</Field>
                <Field Name="EventDate">2008-07-02T16:42:52Z</Field>
              </Method>
            </Batch>
          </updates>
        </UpdateListItems>
      </soap:Body>
    </soap:Envelope>

     

     

     

     

     

    Thursday, July 10, 2008 5:09 PM
  • Hi rmao78,

    I am having same issue as you first encountered but the workaround didn't work for me. I am sending the datetime values in UTC and also followed the procedure as you did, but still it is interpreted as local time and shows the same value in share point.
    My scenarios is also same with server being in different time zone so i am just looking at way to update datetime fields in UTC format and rest will be taken care by share point.

    Here is my sample request. It doesn't work.

    <Batch OnError="Return" DateInUtc="True">        
    <Method ID="1" Cmd="Update">        
    <Field Name="ID">1</Field>        
    <Field Name="DateTimeColumn">2008-07-02T14:42:52Z</Field>        
    </Method>        
    </Batch>   
     
     
    I see the same value 2/7/2008 2:42pm in sharepoint for that field.
    Kryptonite
    Wednesday, February 25, 2009 4:13 AM
  • Wow, great find!!  I just spent a good couple of hours trying to figure out what the issue was.  This post saved me countless more hours trying to come up with my own work around.  Thanks!!
    Monday, June 29, 2009 2:10 PM
  • It does really work... thanks for the help
    Luis
    Monday, February 22, 2010 5:52 PM
  • Wow, great find.  I spent several hours trying to figure this out, trying every combination of pre-defined and custom date formats to try and get this to work.  Will you please share how you found the 'DateInUtc' attribute when it is not documented anywhere?

    Monday, June 21, 2010 9:02 PM