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
Jgk kJgk k 

Changing the Date Format in data export via Command Line Dataloader

Hello ,
I have a requirement to export data from salesforce using commandline dataloader.I have sucessfully extracted data, but the date fields in my current extract are in format YYYY-MM-DD. My requirement is to get date fields in MM-DD-YYYY format. I have tried using FORMAT() but that doesn't work. 
Can anyone suggest me a way to change the format of date fields?

Thanks in advance. 
Best Answer chosen by Jgk k
Alain CabonAlain Cabon
Hi,

I read the source code of the dataloader and there is no post-processing by the CSVwriter of the data read in bulk mode from Salesforce.

You cannot change the format of the witten dates by the dataloader.

The only option if to create a new custom field. 
 
LPAD(TEXT(MONTH( test_date__c )), 2, '0' ) + '-' + LPAD(TEXT(DAY( test_date__c )), 2, '0' ) + '-' + TEXT(YEAR( test_date__c ))

https://github.com/forcedotcom/dataloader/blob/master/src/main/java/com/salesforce/dataloader/dao/csv/CSVFileWriter.java
 

All Answers

Alain CabonAlain Cabon
Hi,

I read the source code of the dataloader and there is no post-processing by the CSVwriter of the data read in bulk mode from Salesforce.

You cannot change the format of the witten dates by the dataloader.

The only option if to create a new custom field. 
 
LPAD(TEXT(MONTH( test_date__c )), 2, '0' ) + '-' + LPAD(TEXT(DAY( test_date__c )), 2, '0' ) + '-' + TEXT(YEAR( test_date__c ))

https://github.com/forcedotcom/dataloader/blob/master/src/main/java/com/salesforce/dataloader/dao/csv/CSVFileWriter.java
 
This was selected as the best answer
Jgk kJgk k
Hi Alain,
If this is the only way, then it doesn't serve my purpose.  Anyways, thanks for letting me know. 
Alain CabonAlain Cabon
The other way means the modification of the source code of the dataloader itself given that we have access to the source code.
Not impossible but time consuming and a new custom field formula is sufficient here.
Otherwise, you modify the exported data (post process) of course (the trivial answer).