I'm using Google Sheets functions. How do I run a function only on every first Monday of the month?

function HideH() {
  var ss = SpreadsheetApp.getActive(),
    target = ss.getSheetByName('Raspored'),
    hsh = ss.getSheetByName('5. tjedan');
  if (ss.getSheetByName('Ne Dirati')
    .getRange(4, 6)
    .getValue() === 1) {
      var width = 165;
  } else {
    width = 143
  for (var i = 4; i < 8; i++)
    target.setColumnWidth(i, width);

1 Answer 1


Use a time-driven trigger that runs every day including a comparison of the current day to check if its the first Monday of the month, if it isn't, do nothing, if it is, then do whatever should be done.

  • Use JavaScript's new Date() to create a date object with the current date.
  • Use getDay() on the date object to get a serial number representing the day of the week, 0 for Sunday, 1 for Monday and so on.
  • Use getDate() on the date object to get the day of the Month.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.