Answer the question
In order to leave comments, you need to log in
How to compare dates in different cells using script?
There is the following working piece of script:
while (i<=1500&&s.getRange(i, col1).setNumberFormat("0.000").getValue()===s.getRange(i+1, col1).setNumberFormat("0.000").getValue()&& s.getRange(i+1, col1).isBlank()===false) {
s.getRange(i, col1).setNumberFormat("dd.mm.yyyy");
i++;
count++;
}
Answer the question
In order to leave comments, you need to log in
It also should not "plow". This is not a horse.
I tried to understand without an example what this code does, and came to the conclusion that all this should be changed at least to
const values = s.getRange(1, col1, s.getLastRow(), col1).getValues();
const count = values.filter(
(row, i, arr) => arr[i + 1] && compareAsDate_(row[0], arr[i + 1][0])
);
console.log(count);
/**
*
* @param {any} a
* @param {any} b
*/
function compareAsDate_(a, b) {
return (
a && b && a.getTime && b.getTime && a.toDateString() === b.toDateString()
);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question