Created
June 20, 2014 20:12
-
-
Save ajot/88ca5377cbde7963c552 to your computer and use it in GitHub Desktop.
Get Last Updated Date - Google Spreadsheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function onEdit() { | |
| Logger.log("Starting"); | |
| var email = Session.getEffectiveUser().getEmail(); | |
| Logger.log(email); | |
| // Getting the Current Spreadsheet | |
| var s = SpreadsheetApp.getActiveSheet(); | |
| var r = s.getActiveCell(); //Getting the active cell | |
| if( r.getColumn() != 2 ) { //checks the column | |
| if( r.getRow() != 1 ) { //Excluding the header | |
| var row = r.getRow(); | |
| // var time = new Date(); | |
| // time = Utilities.formatDate(time, "GMT-08:00", "MM/DD/yy"); | |
| var formattedDate = Utilities.formatDate(new Date(),"GMT-04:00","MM-dd-yyyy 'at' HH:mm:ss z"); | |
| Logger.log("formattedDate"); | |
| SpreadsheetApp.getActiveSheet().getRange('K' + row.toString()).setValue(formattedDate); //Inserting the date in the cell | |
| // Getting the current user. Needs Auth | |
| var email = Session.getActiveUser().getEmail(); | |
| Logger.log(email); | |
| SpreadsheetApp.getActiveSheet().getRange('E' + row.toString()).setValue(email); | |
| }; | |
| }; | |
| }; |
Hello
thank You for Your answer. but how to get email receiving date by specific email addresses list to. so all dates could fill the row?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Are you aware of a script to get the last updated date and email of the modifier of a separate spreadsheet and insert those into cells A and B. When I have someone else update the spreadsheet with the key I am still getting my name and it looks like the date the spreadsheet of the scripts modified date and not the other spreadsheet.
function myfunction() {
var lastUpdate = DocsList.getFileById('Key').getLastUpdated();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var user = Session.getActiveUser().getUserLoginId();
var sheet = ss.getSheetByName("LastUpdated");
var cella = sheet.getRange("A1");
var cellb = sheet.getRange("B1");
var date = Utilities.formatDate(new Date(), "GMT", "MM-dd-yyyy");
cella.setValue(" User:" + user);
cellb.setValue(date);
}