I am missing some sort of conversion here or something when using google apps script to find the difference between times. I am creating a timesheet to be used by school staff in google sheets. Using baby steps, I am trying to find the number of hours/minutes the employee entered on the first Sunday entry; 6:00AM - 9:00AM, on 6/14/2020. My code is giving me 10,800,000; and the dates in the log are not matching what the spreadsheet shows, which tells me it needs to know more? Once I can understand this, I can move on. Thank you.
This is the code I'm using:
function onEdit() {
// get the current sheet
var ss = SpreadsheetApp.getActiveSheet();
// set variables to be used for Sunday, Week 1
var Week1Sun1_In = ss.getRange('B7').getValue();
var Week1Sun1_Out = ss.getRange('B8').getValue();
var Week1Sun1_Hours = ss.getRange('B9').setValue(Week1Sun1_Out - Week1Sun1_In);
Logger.log(Week1Sun1_In,Week1Sun1_Out,Week1Sun1_Hours);
}
And this is what I see in the log:
LOGS: [20-06-19 11:43:59:581 PDT] Sat Dec 30 06:00:00 GMT-05:00 1899 Sat Dec 30 09:00:00 GMT-05:00 1899 Range
And this is a snippet from the spreadsheet that will show what I'm trying to do: