You know my programming skills s**k very hard, and you have recently created a script which determines the last business day of the month in JS Script. You guess it, now it's time to determine the first business day of the month

Also in this case it's used to set a variable to "yes" if it's the case.
I was playing around with the offset for a long time, tried another script, and anotherone, but I failed (ofcourse) to get it done. Can you help me out?
This was the code for the last business day (I already renamed the function):
Code: Select all
function FirstBusinessDayOfMonth(year, month) {
var date = new Date();
var offset = 0;
var result = null;
if ('undefined' === typeof year || null === year) {
year = date.getFullYear();
}
if ('undefined' === typeof month || null === month) {
month = date.getMonth();
}
do {
result = new Date(year, month, offset);
offset--;
} while (0 === result.getDay() || 6 === result.getDay());
return result.getVarDate();
}
//LogMessage(FirstBusinessDayOfMonth(2018, 4))