| Author |
Message |
Rachel Devons
Guest
|
Posted:
Tue Jan 18, 2005 3:11 am Post subject:
Setting metadata date fields in SPS 2003 |
|
|
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 |
|
|
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 |
|
|
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 |
|
 |
|
|
|
|