Wednesday 9 November 2011

Salesforce Date fields are really DateTime fields

Migrating data into Salesforce takes up a lot of my time, and I use Apex Data Loader to carry out most of the heavy work. Usually I test migrate into my client's sandbox and then migrate into their production instance. However, one recent client insisted that their own support team carry out the final migration into production. So I handed over the csv files and my migration notes, but they struck a number of errors with environmental differences, especially dates.

For my Australasian clients I have always used data loader with the 'European Date Format' checkbox checked. If you don't know what this is, go to Settings and look for 'Use European date format (dd/mm/yyyy)'.
This option allows you to enter dates without transforming them into North American format (mm/dd/yyyy) or the full Salesforce format (yyyy-mm-ddThh:mm:ss.sssZ).

Unfortunately the person migrating my data into the production instance had different settings to me. They did not have the European Date format checked and their Time Zone setting was different, meaning that Salesforce was transforming 12/03/1992 into 3/12/1992 and occasionally subtracting a day due to the time zone difference; my fault for not specifying exactly what my settings were.

However, the best solution is to make sure all dates are always in the full, correct Salesforce datetime format, instead of formatted as dates only. Loading dates in the full datetime format ensures that Salesforce recognises the correct date, regardless of the data loader date format and time zone settings.

Best Practice: Always use the full yyyy-mm-ddT00:00:00.000Z format when entering dates and times into Salesforce using data loader or any other data migration tool.

No comments:

Post a Comment