Play Games

Search This Blog

Friday, February 9, 2018

Apex Code to get previous Monday based on today's date Salesforce

Sample Code:

DateTime previousMondayDate = system.now();
while(!previousMondayDate.format('EEEE').equalsIgnoreCase('Monday')){
previousMondayDate = previousMondayDate.addDays(1);
}
System.debug('Previous Monday Date:'+previousMondayDate);

Output:

No comments:

Post a Comment