You need to sign in to do that
Don't have an account?
bhanu_prakash
date need to be previous month
help me to write trigger if date is less than or equal to 10 , i need to upate previous month last date . if it is above 10 we need to update same day
ex: date : 04-Jun-17 output -- 31-may-17
ex: date : 10-jun-17 output -- 31-may-17
ex: date 11-jun-17 output -- 11-jun-17
ex: date : 04-Jun-17 output -- 31-may-17
ex: date : 10-jun-17 output -- 31-may-17
ex: date 11-jun-17 output -- 11-jun-17
Replace d1 and d2 with your actual date fields.
Please mark as BEST ANSWER if it helps.
date d1;
date d2;
list<Event__c > l = trigger.new;
for(Event__c i:l){
if(d1.day()<=10){
Integer NumberOfDays = date.daysInMonth(d1.Year(), d1.Month()-1);
d2 = date.newInstance(d1.Year(), d1.Month()-1, NumberOfDays);
}
else if(d1.day()>10){
d2 = d1;
}
}
i tried to write trigger like this.please help me where iam wrong
Copy__C(Output need to be 31-05-17)
I have tried with formual field also :
IF(MONTH(Date__c) < 12,
IF(DAY(Date__c) > 10, Date__c, DATE(YEAR(Date__c), MONTH(Date__c)-1,30)),
IF(DAY(Date__c) > 10, Date__c, DATE(YEAR(Date__c) + 1, 1, 30)))
but iam getting output as 01-05-17 i need to be 31-05-17