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
Chandra SfdChandra Sfd 

SOQL to extract records created last year this month using command line data loader

I would like to schedule command line data loader every month to extract EmailMessages that were created last year current month. Could you please provide your inputs on how to write the SOQL to do this? Thank you!
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Chandra,
Please check the below code on records created last Year, this Month.
Integer year = Date.today().year() - 1;
Integer month = Date.today().month();
List<Account> accnts = [SELECT id FROM Account WHERE CALENDAR_YEAR(CreatedDate) =: year AND CALENDAR_MONTH(CreatedDate) =: month];

Hope it will be helpful.

Please mark it as best answer if the information is informative.

Best Regards
Rahul Kumar
Chandra SfdChandra Sfd
Hi Rahul, thank you for your response. I would like to know how to use this query in process-conf.xml for command line data loader.