Setting metadata date fields in SPS 2003
Windows Server Forum Index Windows Server
Server discussion on Windows platform.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web winserverhelp.com
Setting metadata date fields in SPS 2003

 
Post new topic   Reply to topic    Windows Server Forum Index -> Portal Server Development
Author Message
Rachel Devons
Guest





Posted: Tue Jan 18, 2005 3:11 am    Post subject: Setting metadata date fields in SPS 2003 Reply with quote

I've been able to set custom fields (metadata) on documents in SPS 2003 by
doing the following:

file.Item["<field name>"]="<field value>";
file.Item.Update();

Where file is a SPFile object that contains the document.

However, I have a field that is a date field and when I try to set this
field, I receive the error "Specified cast is invalid.". I've tried adding
the date various formats, including MM/DD/YYY and YY/MM/DD and
YYYY-MM-DDTHH:MMZ. All with no luck.

From what I understood, the metadata in SPS 2003 is all strings, so I'm not
sure why I am getting this error. The document library was imported from SPS
2001 using SPIN/SPOUT so perhaps that might have something to do with it.

Can anyone shed any light on this? Do I need to cast the field value to
something? Any help would be greatly appreciated!
Back to top
DJA
Guest





Posted: Tue Jan 18, 2005 8:46 am    Post subject: Re: Setting metadata date fields in SPS 2003 Reply with quote

As far as I remember you should use the DateTime type as a value to a
date field in SharePoint. Try using Convert.ToDateTime(string) to get a
DateTime object and use it as the value.
Back to top
Gabriele Del Giovine [MVP
Guest





Posted: Tue Jan 18, 2005 11:57 pm    Post subject: Re: Setting metadata date fields in SPS 2003 Reply with quote

Rachel Devons wrote:

Quote:
However, I have a field that is a date field and when I try to set
this field, I receive the error "Specified cast is invalid.". I've
tried adding the date various formats, including MM/DD/YYY and
YY/MM/DD and YYYY-MM-DDTHH:MMZ. All with no luck.

yyyy-MM-ddTHH:mm:ssZ


Warning: case sensitive. Don't ask why.
Back to top
 
Post new topic   Reply to topic    Windows Server Forum Index -> Portal Server Development All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




New Topics Powered by phpBB