Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
for loop through dates to check if the are the same

I need to run a loop that checks if dates are the same and if they are delete the duplicate. We have visitors that come to our store multiple times. Data entry gets convoluted. So I need to run my database through a loop that cleans up duplicated dates for individual customers. I'm struggling with the date issue. I thought I could use getTime(). But it is returning the current time not the logged entry. I used a practice loop of only 3 entries, but the loop would run through about 12,000 entries.

function cleanUpBebacks() {
  const myGoogleSheet = SpreadsheetApp.getActiveSpreadsheet();
  const importSheet = myGoogleSheet.getSheetByName('Import from Hubspot');

  var lastRow1 = importSheet.getLastRow();

  for (r = 2; r <= 4; r++) {

    var dateVisited1 = Date("importSheet.getRange(r,36).getTime()");
    var dateVisited2 = Date("importSheet.getRange(r,37).getTime()");
    var dateVisited3 = Date("importSheet.getRange(r,38).getTime()");
    var dateVisited4 = Date("importSheet.getRange(r,39).getTime()");
    var dateVisited5 = Date("importSheet.getRange(r,40).getTime()");
    var beBackRange = importSheet.getRange(r, 42).getValue();

    if (dateVisited5 === dateVisited4) {
      importSheet.getRange(r, 40).setValue("");
    }

    else if (dateVisited4 === dateVisited3) {
      importSheet.getRange(r, 39).setValue("");
    }

    else if (dateVisited3 === dateVisited2) {
      importSheet.getRange(r, 38).setValue("");
    }


    else if (dateVisited2 === dateVisited1) {
      importSheet.getRange(r, 37).setValue("");
    }

    else if (dateVisited2 === "") {
      getRange(beBackRange.setValue("No"));
    }

    Logger.log(lastRow1);
    Logger.log(dateVisited1);
    Logger.log(dateVisited2);
    Logger.log(dateVisited3);
    Logger.log(dateVisited4);
    Logger.log(dateVisited5);
    Logger.log(beBackRange);
  }
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!