Web Applications Stack Exchange is a question and answer site for power users of web applications. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Need help in adding another function using the below script. I would like to have a timestamp "start" and "end" on two different columns, whenever the other two separate columns are edited. Based on the below script, I could only have one time stamp, from one column which is the column 2 and time stamp on column 10.

function onEdit() 
 var s = SpreadsheetApp.getActiveSheet();
 if( s.getName() == "Sheet1" ) { //checks that we're on the correct sheet
   var x = s.getActiveCell();
   if( x.getColumn() == 2 ) { //checks the column
     var nextCell = x.offset(0, +8);
     if( nextCell.getValue() === '' ) //is empty?
       var time = new Date();
     time = Utilities.formatDate(time, "GMT", "hh:mm");
share|improve this question

See if this helps ?

function onEdit(e) {
var s = e.source.getActiveSheet(),
    watchCols = [2, 5],
    offsetCol = [8, 10],
    ind = watchCols.indexOf(e.range.columnStart)
    if (s.getName() !== "Sheet1" || ind === -1) return;
e.range.offset(0, offsetCol[ind])
    .setValue(!e.value ? null : Utilities.formatDate(new Date(), "GMT", "hh:mm"))
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.