[SalesForce] CSV Date format for Salesforce Date (or Date Time)

I am trying to insert data from csv file into Salesforce (using Python file).

Bottom is portion of Python script to fetch the data from csv file and into Salesforce database.

for line in file: 
    line = line.strip()
    line_parts = line.split(",")

    if not line_parts[0] in 'Date':
        sf.Table__c.create({'Date__c': line[0], 'Survey__c': line[1]})

The output format of 'Date' is 7/23/2017 .

What should be the format inside csv file so that it would take into "Date" or "Date Time" format in Salesforce?

I am trying to use Date and Time such as "7/23/2017 9:00:00 AM".

When I tried with this format in csv, it generated this error

Response content: [{u'errorCode': u'JSON_PARSER_ERROR', u'message': 
u'Cannot deserialize instance of date from VALUE_STRING value Date or 
request may be missing a reuqired field at [line:1, column:17]'}}

I even tried with simple "7/23/2017" format, and still getting the same error.

I guess the challenge is how to format the cell as acceptable format as illustrated on the bottom.

Best Answer

The "Date" field acceptable formats

  • YYYY-MM-DD

AND

"Date Time" field acceptable formats

  • YYYY-MM-DD hh:mm:ss
  • YYYY-MM-DDThh:mm:ssZ
  • YYYY-MM-DDThh:mm:ss.sssZ
Related Topic