WeirdGeek

Data Science | Machine Learning | Automation

  • Data Analytics
  • Python
  • Data Science
  • Google Apps Script
  • Machine Learning
  • Artificial Intelligence
  • SQL Server

10/03/2020 By WeirdGeek Leave a Comment

Getting Spreadsheet creation and modification date using GAS

When you are working as an Analyst, your main part of the job is to create reports with important KPI which help business to understand in detail about how their business is performing. Also performing automation or creating automated reports are one more task. While working and automating Google Spreadsheet, you have come across a situation where you want to get Spreadsheet creation and modification date. This task can be automated using the Google Apps Script (GAS).

Here in this post we will see how you can automatically update the Spreadsheet creation and last modification date in a cell using Google Apps Script.

Spreadsheet creation and modification time using Google Apps Script

Below is the Google Apps Script code which will get the Google Spreadsheet creation date along with the last modification date as well.

function GetDate() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var s = ss.getSheetByName('Sheet_name');

  var dateCreated = DriveApp.getFileById('Google_Spreadsheet_ID').getDateCreated()
  s.getRange('B7').setValue(dateCreated);

  var lastUpdated = DriveApp.getFileById('Google_Spreadsheet_ID').getLastUpdated()
  s.getRange('B8').setValue(lastUpdated);
};

 

Here in the above code, we are checking the current active spreadsheet and then getting the sheet name which we are looking for. Then we have created two variable datecreated and lastupdated, and using the spreadsheetID we are fetching the .getDateCreated() and .getLastUpdated() methods of the FILE class and finally putting the values in the “B7” and “B8” cells respectively.

 

To get more detailed knowledge about Google Apps Script, you can check the official website. Also if you want to explore more codes/posts related to Google Apps Script on our website, then you can find it here.

If you have any questions or if you need any help please get in touch with me using the comment section below.

Related posts:

  1. Import CSV file data to Google Spreadsheet using Google Apps Script
  2. Navigate from one Google Sheet to another using GAS
  3. Find and Copy files of specific types using Google Apps Script
  4. Google Apps Script Code to find the days of the week

Filed Under: Google Apps Script Tagged With: GAS, Google, Google Apps Script, Google Drive, Google Sheets

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Subscribe to my Blog !!

Enter your email below to subscribe my blog and get the latest post right in your inbox.

  • Home
  • Terms
  • Privacy
  • Contact Us

Copyright © 2025 · WeirdGeek · All trademarks mentioned are the property of their respective owners.