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

225
Views
Script for last edited/modified time & date

I have been searching around for a script that will give me the time & date that a google sheet was last modified.

I have a list of all the google sheet workbook IDs in column E of a sheet called 'Planner Directory' and I would like it to return the time & date last modified in column F.

This would be really helpful if anyone can assist?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Since you already have all the data in a Google Sheet, I think the easiest way to get this working automatically is using Google Apps Script. I will leave an example of how it would work.

Try this code:

function myFunction() {
  var ss = SpreadsheetApp.getActive().getSheetByName("Sheet20"); // Change it to the name
                                                                 // of the sheet you. are using
  var range = ss.getDataRange();
  var values = range.getValues();
  for(var i=1; i<values.length; i++)
  {
    values[i][1] = lastModifiedTime(values[i][0]); // 0 is the column number in my testing sheet
                                                   // where the IDs are.
                                                   // 1 is the column number where the time will be.
  }
  range.setValues(values);
}

function lastModifiedTime(id)
{
  var file = DriveApp.getFileById(id);
  return file.getLastUpdated();
}

Input data:

Replace the Sheet ID fields with valid IDs.

enter image description here

Result:

enter image description here

Remember to change the format of the column where you want you have the last modified time to Number > Date time.

Now, in order for you to automate this script you can use a time-driven trigger from Google Apps Script so that the script runs every 5, or 10 minutes for example and so that you can always get the latest time in the results.

Trigger:

enter image description here

References:

  • Method: getLastUpdated()
  • Time-driven triggers
about 4 years ago · Santiago Trujillo Report
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!