Play Games

Search This Blog

Thursday, June 15, 2017

How to query records of an object which were created in Last 24 hours in apex salesforce

Problem: I want to fetch/process all the lead records that were created in Last 24 hours
Solution: 
Use SOQL query like this
datetime objDateTime = System.now()-1;
List<Lead> lstLeads = new List<Lead>();
lstLeads = [select id,name from Lead where createddate >=:objDateTime];
System.debug('Leads:'+lstLeads);
Output:

No comments:

Post a Comment