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
nagachandra knnagachandra kn 

How to get all the accords which are older than 14 days? SOQL query

Hi All,

I have  a requirement where i need write a batch class to delete all the records which are older than 14 days . How to write the SOQL for the same? 
Ramssf70Ramssf70
Hi Nagachandra,
you can write  query like following way
List<account> acclist=[select id,name,createddate from account where createddate=LAST_N_DAYS:14]; 

if you write query like this you will get records  which are created fourteen days before .
Anilkumar KotaAnilkumar Kota

Hi Nagachandra ,

Refer the below link for more details .

https://developer.salesforce.com/forums/?id=906F00000009357IAA

Replace the query with the following query .

Select * from case where WHERE CreatedDate = LAST_N_DAYS:14