How Do i need to Write APex Code for the CloseDate on Opportunity object?
Opportunity Opp= new Opportunity();
Opp.Name='Beginner';
Opp.CloseDate= ?????;
Opp.StageName='Proposal';
insert Opp;
can someone help me out with this ?
How Do i need to Write APex Code for the CloseDate on Opportunity object?
Opportunity Opp= new Opportunity();
Opp.Name='Beginner';
Opp.CloseDate= ?????;
Opp.StageName='Proposal';
insert Opp;
can someone help me out with this ?
You could use
Opp.CloseDate= System.today();
or
Opp.CloseDate = Date.newInstance(2017, 12, 31);
If you have a string, then you should convert by either of the following ways:
Opp.CloseDate = Date.parse('10/14/2017');
Opp.CloseDate = Date.valueOf('2017-12-15');
For more information, refer Date Class
You can also use TODAY() function as well. for example, opp.closeDate=TODAY()+1; will give you tomorrow's date or ,opp.closeDate=TODAY() will give you today's date