function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RameshwarRameshwar 

Assigning date value in date field

Hi,
 
I am facing problem in setting the standard Task.ActivityDate by using .NET  
It shows me following error
 
+++++++++++++++++++++++++++
'4/11/2008' is not a valid value for the type xsd:date
 
'4/11/2008 12:00:00 PM' is not a valid value for the type xsd:date
'2008/4/11' is not a valid value for the type xsd:date
 
+++++++++++++++++++++++++++
 
 
Can anybody give me idea how to set the date in a standard object field ?
 
Help me to pull out from this problem
 
Thanks
 
Rameshwar
 
HardhatHardhat
For the Salesforce date type, use a conversion like:

xmlNode.InnerText = tmpDate.ToUniversalTime().ToString("yyyy-MM-dd");
 
RameshwarRameshwar
It is working now by setting value from 4/14/2008 to 2008-04-14
 
Just prefix 0 infront of assigned date (4/14/2008 )
 
Thanks for your suggested code.
 
 
Rameshwar
 
jeremyfrey1jeremyfrey1
XmlConvert.ToString(your date, XmlDateTimeSerializationMode.Utc) or XmlConvert.ToString(offset) is probably the best way of converting it to the format SFDC expects.  You eliminate the need to continuously type out or store the ISO 8601 date format, as well as the need to remember to convert your local datetime to UTC.