# Time stamp update

**URL:** <https://community.glideapps.com/t/time-stamp-update/1382>\
**Category:** Ask for Help\
**Created:** [October 25, 2019, 3:55pm UTC](https://community.glideapps.com/t/time-stamp-update/1382 "2019-10-25T15:55:07Z")\
**Posts on this page:** 1\
**Showing post:** 33

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 8, 2020, 4:07am UTC](https://community.glideapps.com/t/time-stamp-update/1382/33 "2020-05-08T04:07:51Z")

</div>

Hi John, sorry for the late reply but here’s the working script.

```
// The column you want to check if something is entered.
var COLUMNTOCHECK = 2;
// Where you want the date time stamp offset from the input location. [row, column]
var INITIAL = [0,1];
var LATEST = [0,2];
// Sheet you are working on
var SHEETNAME = 'Change test'
 
function onChange(e) {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();
  //checks that we're on the correct sheet.
  if(sheet.getSheetName() == SHEETNAME) { 
    var selectedCell = ss.getActiveCell();
    //checks the column to ensure it is on the one we want to cause the date to appear.
    if(selectedCell.getColumn() == COLUMNTOCHECK && selectedCell.getValue() == true) { 
      var initialcell = selectedCell.offset(INITIAL[0],INITIAL[1]);
      var latestcell = selectedCell.offset(LATEST[0],LATEST[1]);
      if(initialcell.getValue() !== ''){
      latestcell.setValue(new Date());}
      else {
      initialcell.setValue(new Date());}
      }
  }
}

```

The setup: a spreadsheet with column B containing the check boxes, column C as initial change and column D as latest change.

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/c/cf0a14581ebeae86fcdf08955563901f5ddc856e.png)

Input your script into the script editor, notice the fields you have to change are:

- var COLUMNTOCHECK = 2 =\> Change number 2 to whatever column contains your checkbox. Here it’s column B, hence number 2.
- var SHEETNAME = ‘Change test’ =\> Change ‘Change test’ to your sheet’s name.

Then navigate to Edit \> Current Project’s Triggers and set the conditions like what @Mrinal_Chakraborty showed.

A demo on how it works.

![ezgif-1-4a0024634334](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/e/ed4c95a226147c2474d46dcd59b0c56f8d8c822f.gif)

---

_[View the full topic](https://community.glideapps.com/t/time-stamp-update/1382)._
