I am currently writing a c# .Net application that makes use of the salesforce API. I am sending account objects with datetime fields.
my datetime objects are all in this format "dd/MM/yyyy HH:mm:ss" which is also the same format of the date fields that is returned when I do a simple query "SELECT Name, Date FROM Account WHERE ID != null" - I have set a date in the a test account in salesforce manually prior to the query. I have checked everything that has to do with date format and I am confident that I am sending the correct datatype and datetime format to salesforce.
My problem is Salesforce seems to leave the Date field blank. Anyone know of a way I can make sure Salesforce is accepting the date details.
DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
dtfi.FullDateTimePattern = "dd/MM/yyyy HH:mm:ss";
dtfi.DateSeparator = "/";
string _TempRangeEndDate = "2013-08-31"
DateTime objDateRangeEnd = Convert.ToDateTime(_TempRangeEndDate,dtfi);
_TempAccount.Date_End__c = objDateRangeStart; //Salesforce not accepting converted format which is "31/08/2013 00:00:00"
my datetime objects are all in this format "dd/MM/yyyy HH:mm:ss"
No, they're not. At least not if you're talking about .NET DateTime
values or database fields. Neither of those implicitly have formats - they're just values.
You should avoid using text at all when you don't need to. So when you send a query to SQL, you should use parameterized SQL with the DateTime
values as parameters... no need for string conversions at all.
You say that Salesforce is "not accepting converted format which is "31/08/2013 00:00:00"" - but you're just assigning a DateTime
value. That doesn't have a converted format. I think you need to look at your whole data flow carefully, and minimize string conversions. Where possible, stick to just using DateTime
. Then check any errors from Salesforce very carefully. The problem may well not be what you think it is. (It's hard to tell as you haven't told us what sort of error Salesforce is giving you.)
the .NET SOAP stack won't send dateTimes (and some other primative types like numbers) without you setting the additional speciified flag, e.g.
_TempAccount.Date_End__c = DateTime.Now;
_TempAccount.Date_End__c_Specified = True;
If you don't set this flag the .NET Soap stack doesn't serialize that element and its never sent to salesforce. (and so the field remains blank)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With