You need to sign in to do that
Don't have an account?
srilakshmib87
Filer the records retreived by created Date
Hi,
I want to query and retreive records from one object whose created dateis less than 3 days from current date.
Since createdDate field is a standard field of data type datetime.I am trying to filter it out by giving the following in the where condition but i m getting query error.
CreatedDate.date< =today-3;
Can anyone please help me in this.
Thanks,
Srilakshmi B
Hi,
You can use like the below - "CreatedDate <=: Date.Today() -3".
Hope this helps.
Thanks
Hi,
Thanks for your reply but even I faced error with that approach.So, finally i was able to acheive by following code.
datetime dt= datetime.now();
Date d =dt.Date()-3;
and in the where condition of the query i gave CreatedDate >=:d and CreatedDate < =today to retreive the records created in last three days.
Thanks,
Srilakshmi B
you can use this SOQL Query to retreive your records :
integer i = [select count() from account where CreatedDate <=: system.now()-10 T00:00:00+00:00];
Refer this link http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select_dateformats.htm
for more information.
Hope this helps.