You need to sign in to do that
Don't have an account?
punuru kirankumar
how to add first day of month in date field from apex
Hi ,
I have a field called date in that field while creating records from after trigger i need to add first date of the month in that field.any ideas?
thanks
I have a field called date in that field while creating records from after trigger i need to add first date of the month in that field.any ideas?
thanks
Actually i am creating 3 records at a same time using after insert trigger out of those 3 records in the first record date field i need to put
System.Date.today().toStartOfMonth(),for the second record i need put next month first day of month ,for third record i need to add 3 rd month 1 st date.
Here is my code:
trigger createProcedure on Opportunity(after insert) {
//createProcedures.createForeCastProcedures(trigger.new);
List<Procedure__c> lstToInsert = new List<Procedure__c>();
for(Opportunity opp:trigger.new){
for(integer i=1;i<=3;i++){
Procedure__c proc = new Procedure__c ();
proc.Account__c = opp.AccountId;
proc.Status__c = 'New';
if(i ==1)
proc.Start_Date__c = System.Date.today().toStartOfMonth();
if(i ==2)
proc.Start_Date__c = date.today()+30;
if(i ==3)
proc.Start_Date__c = date.today()+60;
lstToInsert.add(proc);
}
}
if(lstToInsert.size()>0)
insert lstToInsert;
}
can you tell me how to set for second and third record.
thanks
Thanks let me know if it helps you
thanks