function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Calculate Date not holiday

I would like to add time. Do not count holidays.


Date + 4 day if Start Thursday Ended Tures. Thursday  Friday Saturday Sunday Monday Tues. 

Do you have guide me.


Thank you so much.


If you are just concerned with weekends you could do as I've done. I have a general "Utils" class that contains a few helper methods. One of them is "addBusinessDays". There may be a more elegant way of doing it, but this works well for our purposes.



public static Date addBusinessDays(Date oldDate,Integer addMe){
   		Date newDate = oldDate.addDays(addMe);
   		Date weekStart = newDate.toStartOfWeek();
   		Integer dateDiff = weekStart.daysBetween(newDate);
   		if(dateDiff == 6){
   			newDate = newDate.addDays(2);
   		else if(dateDiff == 0){
   			newDate = newDate.addDays(1);
   		return newDate;