You need to sign in to do that
Don't have an account?
KVaishna
Records created in last 24 hours
Hi,
I want to get records created in last 24 hours in Apex SoQL query like
'Select Id, name, recordtypeid from Opportunity where createddate = LAST 24 Hours'. How can I do that?
I can get it using system.now() - 1 but SoQL query does not support returned datetime format.
Thanks
- Kunjan
datetime dt = System.now()-1;
List<Opportunity> ops = [select id from opportunity where createdDate > :dt];
All Answers
How about using the date literals?
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select_dateformats.htm
where createddate > LAST_N_DAYS:1
You could always calculate the exact date string and use that too
Thanks for the reply.
LAST_N_DAYS:1 would give me from 12 AM to 11:59 PM of that particular day. It would not give me specific last 24 hour range at any time in the day.
datetime dt = System.now()-1;
List<Opportunity> ops = [select id from opportunity where createdDate > :dt];
Thanks SimonF.
What if i need this in an SOQL query for DataLoader?
WHERE CreatedDate > LAST_1_HOUR