+ Start a Discussion
Balasubramani DhanapalBalasubramani Dhanapal 

opportunities close date as today()?

Hi all, 
           I am beginer of salesforce.Please any one help me  the following code implementation. how to Write Apex class to update all the opportunities close date as today()?

Thanks in advance
Best Answer chosen by Balasubramani Dhanapal
Apoorva SharmaApoorva Sharma
List<Opportunity> opplist=[select closedate from Opportunity];
for(Opportunity opp: opplist){
opp.closedate=date.today();
}
database.update(opplist,false)
 

All Answers

PrakashbPrakashb
Hi,

If you want to update your existing opportunities you can use data loader to update all your existing opportunities.

Any reason you need apex code implementation?

if you need to update all existing opportunities one time without data loader then you can write a  code in Developer console to update opportunities.

Thanks
Prakash 
Chitral ChaddaChitral Chadda
Declare variable as follows:
Date Tdate = System.today();

next do this,
opp.CloseDate= Tdate;
it wud work for you.
Apoorva SharmaApoorva Sharma
List<Opportunity> opplist=[select closedate from Opportunity];
for(Opportunity opp: opplist){
opp.closedate=date.today();
}
database.update(opplist,false)
 
This was selected as the best answer