It may seem complicated, but scripts are only as smart as the instructions they get :) The simplest things can tend to be the toughest to code, and date/times are one of those. Consider leap years in what you are trying to do... lol
But you have made it easy for yourself by already including your paydates. What I would do is grab the column of paydates, put them in an array, and then just see if the current date is in the array. If yes, change the date. Then I would just have a daily trigger to run the code and not worry about installing triggers based on date and all that.
So say you put your paydates just by themselves on another tab called "Paydates". Make sure they are in the same format as "MM/dd/yyyy".
Something like this set to run daily should do the trick. (My changes to your code are highlighted)
//passing in the date from below function
function ChangeDate(date) {
const ss = SpreadsheetApp.getActive();
const timezone = ss.getSpreadsheetTimeZone();
const sh = ss.getSheetByName('Employee');
// const date = Utilities.formatDate(new Date(), timezone, "MM/dd/yyyy"); can be removed since date is being passed in
sh.getRange('A7').setValue(date);
}
//this "flat" is a helper function to flatten a 2-dimension array into a 1-dimension array
//it converts this: [ [date1], [date2], [date3] ]
//to this (which is much easier to work with): [ date1, date2, date3 ]
const flat = (arr) => arr.reduce((a, b) => (Array.isArray(b) ? [...a, ...flat(b)] : [...a, b]), []);
function checkDate() {
//Get the paydates and convert to a 1-dimension array
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName('Paydates');
const range = sh.getRange("A1:A");
const data = flat(range.getDisplayValues()); //assuming the formats are correct on the sheet, just grab the existing (display) values
//or condensed as const data = flat( SpreadsheetApp.getActive().getSheetByName('Paydates').getRange("A1:A").getDisplayValues() )
//get today's date
const date = Utilities.formatDate(new Date(), timezone, "MM/dd/yyyy");
//check if today's date exists in the array. If yes, run the ChangeDate function
//if the date is not in the array, it returns "-1", otherwise, it returns the location the within the array where the date matches (e.g., the index), which may be "0", the first array element
if (data.indexOf(date) > -1) {
ChangeDate(date)
}
}
Doing it this way means you don't have to loop through all paydates to find a match, it is either in the array or not. If yes, run the changeDate function.