How to Insert Timestamp in Google Sheets
Learn how to insert timestamps in Google Sheets to track when tasks are completed, using both simple date entries and more complex timestamp functions with Google Apps Script.
Here's how to insert a timestamp . One of the interesting things about Google Sheets is that we keep tasks or statuses, and we want to sometimes know when did these things get done? So we want to add a timestamp . Now, a timestamp is or could be a very complicated thing, but it could also be just the date. If you want to just add the date to a cell, we can use Command semi, and that just adds literally a date. But if you want something a little bit more substantial, let's say a timestamp where it has the date and the time, you might want to do something like this, which is go to extensions app script and we'll say function . Enter timestamp . And we'll take the active range in the spreadsheet. We'll set the value, new and date with a capital D. And parentheses, this is the timestamp. So let's save this and we're over on F two here and let's run.
You see we have a little bit more information. We have exactly the time, we have the date. This is a timestamp , so we can actually format this. Around date time, but how do we do this automatically? We can't be coming to this function and entering it each time. Right. Well, let's add a new function up here called Function on edit. With an E, which is our event or whatever is happening, every single edit. This is a built-in function called on edit that we can say, Hey, anytime we edit anything, uh, meaning a cell on any sheet, uh, do something. But we need to know where we are. So, so we need to know the row, which is gonna be E range . Get row. Variable column is gonna be E range get column, and if the row is greater than one, two, ampersands is, and, and we want column, let's say the A column or
column, one column is equal to one and. We're gonna get a value, E value. This is true or false, so if it's true, we'll go to the spreadsheet , get active sheet . Get the active sheet , get range , which will go to the row. We'll go to the timestamp column , which is five or 1, 2, 3, 4, 5, 6. F is six. Six set value. New Tate, and let's check that. And there we go. We just need to format . These as a date time, and there we go. Every time we check the box, we'll get the timestamp . But let's say we wanna do it when our status is done. So that's the C column. So all we need to do is change the one column to three and the value to done. Let's save that. And switch this one to done. And now that's setting off the timestamp.
So that's cool that you can now set a timestamp anywhere in the sheet based on what you're entering into the sheet. You are watching better sheets here on YouTube. Make sure you check out this video or this video and subscribe right now to get more tips, tricks, how tos, get more out of your Google sheets than you ever have before. I'm excited to be making a ton more videos here. Ask me questions down in the comments and I will answer them in future videos. But for right now, right here, one of these videos is gonna be your next Google sheet.