Hi community,
I'm struggling to understand why this whatsoever perfectly working tiny piece of script stops doing so when (seemingly) the 'start' date and the 'end' date are not in the same month.
I am rather new to Airtable script editor so I couldn't find a step-by-step run mode, or a variable value watcher, but it seems that the 'days' variable is not computed correctly when 'start' and 'end' belong to a different month (for instance, 2024-07-15 and 2024-08-07 - however works perfectly with 2024-07-15 and 2024-07-31, and then 2024-08-01 and 2024-08-07)... leading to not entering the 'for' loop at all.
Any clue anyone? Many thanks in advance!
let table = base.getTable('Man.days');
let inputConfig = input.config();
const start = new Date(inputConfig.StartDate);
const end = new Date(inputConfig.EndDate);
const days = end.getDate() - start.getDate();
var date = start;
for (let i = 0; i <= days; i++) {
let record = await table.createRecordAsync({
['Installation ID']: [{id: inputConfig.InstallationID}],
'Date': date,
['Technician']: [{id: inputConfig.Technician}],
});
date.setDate(date.getDate() + 1);
}