I've just started messing around with Google Apps Script and found something that has me puzzled. I have a spreadsheet with a cell A2 that contains a date. I have created an onEdit() event handler.
If I change the date value, e.value is a number, which is the number of days since 1/1/1900. e.range.getValue() is a date.
Here's a simple example:
function onEdit(e) {
// This returns a number -- number of days since 1/1/1900
SpreadsheetApp.getUi().alert('From event: '+e.value);
// This returns a date
SpreadsheetApp.getUi().alert('From selected range: '+SpreadsheetApp.getActiveSheet().getRange(2, 1).getValue());
// This also returns a date
SpreadsheetApp.getUi().alert('From event range: '+e.range.getValue());
}
I'm sure there's a reason for this that I'm just missing. Can somebody clue me in? Thanks!