0

This question already has an answer here:

Found this script on one of the questions answered in the forum but I don't know enough to make it work. I would like it to time-stamp date and time in column B when they check in and then a separate script when they clock out to time-stamp date and time in column D. Not sure how to do this in Google Spreadsheets. Here is the script below that I found but it will only time-stamp column N when changes are made in column M:

function onEdit() {
 var s = SpreadsheetApp.getActiveSheet();
 if( s.getName() == "Sheet1" ) { //checks that we're on the correct sheet
   var r = s.getActiveCell();
   if( r.getColumn() == 13 ) { //checks the column
     var nextCell = r.offset(0, 1);
     if( nextCell.getValue() === '' ) //is empty?
       var time = new Date();
       time = Utilities.formatDate(time, "GMT", "HH:mm:ss");
       nextCell.setValue(time);
   };
 };
}

Let me know how to change this.

marked as duplicate by ale, jonsca Jan 27 '16 at 0:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2
function onEdit() {
 var s = SpreadsheetApp.getActiveSheet();
 if( s.getName() == "Sheet1" ) { //checks that we're on the correct sheet
   var r = s.getActiveCell();
   if( r.getColumn() == 1 ) { //checks the column(A)
     var nextCell = r.offset(0, 1); //offset to same row, and column B; A+1
     if( nextCell.getValue() === '' ) { //is empty?
       var time = new Date();
       time = Utilities.formatDate(time, "CST", "yyyy-MM-dd' - 'HH:mm:ss");
       nextCell.setValue(time);
     };
   };
   if( r.getColumn() == 3) { //checks the column(C)
     var nextCell = r.offset(0,1); //offset to same row, and column D; C+1
     if( nextCell.getValue() === '' ) { //is empty?
       var time = new Date();
     time = Utilities.formatDate(time, "CST", "yyyy-MM-dd' - 'HH:mm:ss");
     nextCell.setValue(time);
     };
   };
 };
}

Got "Utilities.formatDate" info here

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