+ Start a Discussion
Shwetal DesaiShwetal Desai 

How can i insert Date and DateTime values from .NET to Sforce?

Hi ,

In my sForce Object i have two fields A(Date) and B(DateTime),

now i need to insert values from .NET C# application ...

but if i apply values directly like

sObject__c myObj = (sObject__c)qr.records[i];
myObj.A = DateTime.Parse(txtDate.Text).Date;
myObj.B = DateTime.Parse(txtDateTime.Text);

Then its not inserting values in these fields in sforce..... it remains with null values

how can i insert Date and DateTime values in sforce from .NET C#??

Please Help

Thanks
SuperfellSuperfell
See the sticky at the top of forum "why is my date/bool/number ....."
http://community.salesforce.com/sforce/board/message?board.id=NET_development&message.id=815
Mike LeachMike Leach
For Salesforce Date fields, format the .NET native DateTime object using the following:

tmpDate.ToUniversalTime().ToString("yyyy-MM-dd");

 

For Salesforce DateTime fields, format .NET DateTime using the following:

tmpDate.ToUniversalTime().ToString("s");