I'm trying to make a macro that recognises Friday's date and adds 3 days to that date to skip the weekend and get the following Monday's date. I have a spreadsheet function that adds a new block for every day, updating to today's date. However, it doesn't take into account weekends so it would be great to skip these.
Apologies for the terrible rookie js code.
var date = new Date('July 26, 2019 13:00:00 -0500');
function skipWeekend(date){
while (date.getDate() <= 5 && date.getDate() >0){
console.log("The day is...",date);
date+=1;
} console.log("The day is...",date.getDate()+3);
return (date)
}
skipWeekend(date);
The day is... 24
Ideally want: The date is 'July 29, 2019 13:00:00 -0500'
Thanks for your help
getDate
in the code you've posted. You also have usedand
instead of&&
and are missing some parenthesis . Please create a minimal reproducible example with a runnable stack snippet – adiga'July 22, 2019 13:00:00 -0500'
... A Monday? Maps to'July 29, 2019 13:00:00 -0500'
? That's a whole week and it wasn't even Friday. I'm struggling to make sense of your question. – spender