Create a gist now

Instantly share code, notes, and snippets.

Embed
Datetime operations
global Datetime addBussinessDays(Datetime startDate, Integer iDays)
{
Datetime endDate = startDate.addDays(iDays);
Integer iOffDays = daysOff(startDate,endDate);
return endDate.addDays(iOffDays);
}
global Integer daysOff(Datetime sdate, Datetime edate)
{
Integer iCount = 0;
while (sdate < edate) {
if (sdate.format('E') == 'Sat' | sdate.format('E') == 'Sun') {
iCount = iCount + 1;
}
sdate = sdate.addDays(1);
}
return iCount;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment