- Mark as New
- Follow
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
This below is another code, but problem is that this code skip only first weekend days. For example when i add 14 days, it only skip one weekend days, whereas it should skip all weekend days. // Custom Calculate script for NewDate field
(function () {
// Get date entered into the OrigianlDate field
var sDate = getField("OriginalDate2").valueAsString;
// Convert string to date
var d = util.scand("dddd d mmm yyyy", sDate);
// Get the number of days added, as a number
var days = getField("DaysAdded10").value;
// Add days to date
d.setDate(d.getDate() + days);
// possible adjustment for weekend
var nAdj = 0;
// get the zero based day of the week starting on Sunday
var nDay = d.getDay();
// test for Sunday or a value day value of 0
if(nDay == 0) nAdj = 1; // bump to Monday
// test for Saturday or a day value of 6
if(nDay == 6) nAdj = 2; // bump to Monday
// adjust date
d.setDate(d.getDate() + nAdj); // adjust computed date by needed bump
if (sDate) {
event.value = util.printd("dddd d mmm yyyy", d);
} else {
event.value = "";
}
})();
Views
Replies
Total Likes