Link to public spreadsheet: https://docs.google.com/spreadsheets/d/1pXrUkA-fY1hw3bie4Bv1mamkmzics9dfX59B12spuPI/edit?usp=sharing
Issue: Encountering discrepancies between seemingly identical dates in Google Apps Script. There is a sheet containing dates, and the script checks if one date matches the previous date. Expected output (starting from the second row) should be true, false, true. However, actual output is false, false, false. Any insights on why this discrepancy occurs?
9/8/2020
9/8/2020 // expected true, but returns false
9/15/2020 // expected false, correct
9/15/2020 // expected true, but returns false
Snippet of the code:
// Test code
for (var r = 10; r <= 14; r++){
for (var c = 2;c <= 4; c++){
Logger.log(sh.getRange(r,c).getValue());
Logger.log(sh.getRange(r-1,c).getValue());
Logger.log(sh.getRange(r,c).getValue() == sh.getRange(r-1,c).getValue());
}}
Logger response (showing that dates are objects, but equivalent dates aren't...):
[20-10-25 17:05:30:975 EDT] Tue Sep 08 00:00:00 GMT-04:00 2020
[20-10-25 17:05:30:976 EDT] object
[20-10-25 17:05:30:977 EDT] Tue Sep 15 00:00:00 GMT-04:00 2020
[20-10-25 17:05:30:979 EDT] object
[20-10-25 17:05:30:980 EDT] false
[20-10-25 17:05:30:981 EDT] false
[20-10-25 17:05:30:982 EDT] Tue Sep 15 00:00:00 GMT-04:00 2020
[20-10-25 17:05:30:984 EDT] object
[20-10-25 17:05:30:986 EDT] Tue Sep 15 00:00:00 GMT-04:00 2020
[20-10-25 17:05:30:987 EDT] object
[20-10-25 17:05:30:989 EDT] false
[20-10-25 17:05:30:990 EDT] false