I have simple spreadsheet and need to calculate time ranges, according to the image below:
My rule is basically a simple math operation: (end date - initial date) - "09:00:00"
.
My result column gives me something like: -0:21:00
and it's correct.
I have my columns formatted as "hour" (Format > Number > Hours)
. I need to get the sum up of third column and send the result through e-mail. Part of the code was intentionally omitted. Below my script snippet:
var data = dataRange.getValues();
for (i in data) {
var row = data[i];
var to = row[0]; // e-mail
var total = row[1]; // total column
msg = "Total hours: " + Utilities.formatDate(total, "GMT-0300", "HH:mm:ss");
subject = "Test";
MailApp.sendEmail(to, subject, msg);
}
When I try to format Utilities.formatDate(...)
before sending e-mail, the hour goes wrong. I've tried to remove Utilities
call, passing the hour directly, but it gives me the following result:
Fri Dec 29 1899 23:45:28 GMT-0300 (BRT)
I realized where is my total
var must be a JavaScript Date
object, but it didn't work also. I need that my result column were send by e-mail.