+ 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? 
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 .


Replace the query with the following query .

Select * from case where WHERE CreatedDate = LAST_N_DAYS:14