Home » SharepointRSS

how to enter "10:00:00 AM " into a sharepoint list " Date and Time " field

Hi,

 I am trying to append a record from a excel sheet into a sharepoint list. This record consist a TIME column with values in the format " 10:00:00 AM ". When I try to use CAML query and UpdateListItems webservice

I have the following message in InnerText of theXML node returned by UpdatedListItems

" 0x8102001cInvalid date/time value

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

Please let me know how to populate the list field with " 10:00:00 AM " format or somekind of acceptable time format.

 

Thank you

 

 

3 Answers Found

 

Answer 1

Use the SPUtility.CreateISO8601DateTimeFromSystemDateTime method.

It will put the date  in this format  which is acceptable  to the UpdateListItems method

2009-09-17T14:27:35.5565211+01:00

 

Answer 2

Thank you Steve !. This is entering the date  into list-field in the long format  of m/d/yyyy hh:mm AM/PM

Is there a way I can have have just hh:mm AM/PM ?

 

Also I had to concatenate today's date to the "10:00 AM" string. Else SPUtility.CreateISO8601DateTimeFromSystemDateTime 

would have Dec-30-1889 as the date part and the sharepoint  would take this value as out of range value and throw an exception.

Is there a way round this ?

 

Thank you

 

 

Answer 3

You must give a complete date  string. If you need to make a custom date use the DateTime class's constructor as documented in the link below. And then use the toString method as the argument to the method above.

http://msdn.microsoft.com/en-us/library/272ba130.aspx

 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter