This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hi all,
I am trying to get apps script to work out the amount of elapsed time, but it's throwing up really strange numbers and I can't figure out why.
What I am trying to do is to take a start time and end time (in military time) on Sheet A, have it work out the actual amount of time between start and end in hours and minutes, and enter that on Sheet B.
On Sheet A, the cells in question are formatted to show the value in it as time, and so they read as ##:##:## (I don't really want the seconds there, but the format doesn't give me the option for just hours and minutes...)
What I have tried is:
var anaestheticStart = anaestheticSheet.getRange("P29").getValue();
var anaestheticEnd = anaestheticSheet.getRange("P28").getValue();
var anaestheticTime =(anaestheticEnd-anaestheticStart);
and to enter the value of anaestheticTime into the next available row in column 21 of Sheet B:
surgeryLog.getRange(nextRowSurgeryLog, 21).setValue(anaestheticTime);
The value of P28 is currently 09:10
The value of P29 is currently 10:25
10:25-09:10 should be 01:15, but the cell keeps returning a value of -4500000
Any searches I've done have just turned up examples of building time cards with AM and PM, and those mostly use the built-in formulas in Sheets instead of Apps Script.
Can someone tell me what I'm doing wrong?
Many thanks to the wonderful people in here with the patience to hold us newbie's hands!
Subreddit
Post Details
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/googlesheet...