Automating Date Updates in Google Sheets with Apps Script

Brian Chan
2 min readSep 16, 2023

If you’ve ever used Google Sheets for collaborative work or data tracking, you’ve probably wished for a way to timestamp when changes were made to your data automatically. Well, the good news is, you can achieve just that using Google Apps Script. In this article, we’ll break down a simple yet powerful script that adds dates to your Google Sheet whenever an edit is made, making your data history crystal clear.

Step 1: Open the Editor

Then you will see:

Step 2: Paste the code and save

function onEdit() {
var sheet = SpreadsheetApp.getActive().getSheetByName('demo');
var activeCell = sheet.getActiveCell();
var row = activeCell.getRow();
var time = Utilities.formatDate(new Date(), "GMT", "dd/MM/yyyy");
if (activeCell.getColumn() != 1 && row != 1) {
sheet.getRange('A' + row.toString()).setValue(time);

Imagine you have a Google Sheet named ‘demo’ and want to timestamp every edit made within it. These edits could be anything from updating numbers to adding new information, and you want to keep track of when these changes occurred. That’s where the magic of Google Apps Script comes in.

This script adds a date in the “dd/MM/yyyy” format to the first column of each row (excluding the first row) whenever there’s an edit made in the ‘demo’ sheet, except for the first row and first column, which are typically used for headers or other non-data information.

Step 3: Customization

Now that you understand how this script works, you can use it as-is or customize it to suit your needs. Whether you’re managing an investment portfolio, tracking inventory updates, or collaborating on a budget sheet, automating timestamps with Apps Script can save you time.

Thank you for reading.