Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

Found this script on one of the questions answered in the forum what 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 the clock out to time-stamp date and time in column D. Not sure how to do this google spreadsheet. Here is the script below that I found but it will only time-stamp column N when changes are made in column M. Let me know how to change this.

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);
   };
 };
}
share|improve this question

1 Answer 1

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

share|improve this answer

Your Answer

 
discard

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.