Trigger to update the Date field one day less than to next year

Sample Code:

trigger dateUpdate on Pincode__c (before insert, before update)
{
    for(Pincode__c p : trigger.New)
    {
        p.X1st_Anniversary__c = p.Evaluation_Date__c.addDays(364);
        p.X6th_Anniversary__c = p.Evaluation_Date__c.addDays(2184);
    }
}



Cheers!!!

1 comment:

  1. in this field
    Evaluation_Date__c
    suppose we have date as 2/09/2012
    so what is populated in X1st_Anniversary__c fields? is it

    ReplyDelete