How do I shift Google Sheets duration value from 35:55:00 to 0:35:55? - google-sheets

I have pasted multiple run duration values from Garmin into a Google Sheet. The longer runs (> 1 hour) copy/paste correctly. Eg: 2:10:35. The problem is shorter (< 1 hour) runs. Eg 35:55. The latter are being shown in Google Sheets as 35:55:00. Ie Google assumes 35:55 is 35 hours and 55 mins, not 35 mins and 55 seconds. So for my shorter sub 1 hour durations I need an easy way to convert 35:55:00 to 0:35:55.

As Tom Sharpe said, there is some room for interpretation in the data you have. But assuming that the duration of your runs is always between 10 minutes and 10 hours, we can disambiguate the values as follows:
=if(A1 > 10/24, A1/60, A1)
Numerically, the duration values are measured in days, so A1 > 10/24 means "more than 10 hours". In this case the value gets divided by 60.
Depending on your workout regime you may want to replace the threshold of 10 by another number; perhaps it's safer to say that the runs are always between 5 minutes and 5 hours.

Related

TIme Separator in Google Sheets

I hope everyone reading this is doing well. I am making attendance sheets on Google Sheets that also calculates the salary of the person. It is entirely automated except for one part, the part that calculates salaries.
For that I need to separate the Hours and Minutes worked so that I can calculate the salary accurately based on 60 minutes instead of the first half being in hours and the second from a percentage of 100.
It coverts the hours into days and omits the remaining hours. Please assist. Thank you!
What it does
What it should do
HOUR() returns the hour component of a specific time, so it will always return a value between 0 and 23.
In Google Sheets, times are just numbers where 1 indicates 1 day. So a duration of hh:mm:ss means hh/24 + mm/24/60 + ss/24/60/60 which means hours_in_a_day + minutes_in_a_day + seconds_in_a_day. (You can see this if you format the cell as "Number")
So, if you want to extract the hours from a duration, you have to multiply it by 24 and take the INT().
=INT(B20*24)
Spreadsheet time values such was elapsed hours are in units of days. In your spreadsheet, salary is recorded per hour. To multiply the hours by the salary, first convert the salary per hour to salary per day, and then multiply by the elapsed hours, like this:
=n((B23 * 24) * B20)
The n() wrapper is there just to get the number format right. You can also leave it out and format the formula cell as Format > Number > Currency.
See this answer for an explanation of how date and time values work in spreadsheets.

In Google Sheets, how do I multiply a duration or interval constant? [duplicate]

This question already has answers here:
How to SUM duration in Google Sheets?
(5 answers)
Closed 2 months ago.
This post was edited and submitted for review 2 months ago and failed to reopen the post:
Original close reason(s) were not resolved
I'm making calculations on production cost (in number of resources) and duration.
I have a process that takes 5 minutes. Using the Duration format, I would enter that as 00:05:00.
I want to queue up this process a certain number of times and calculate the total duration. The output should either be something like 16:35:00 or 5 02:15:00. A "d HH.mm.ss" format.
How, in Google Sheets, do I multiply a Duration by an integer to get a total Duration? To be clear, I am not doing a summation of a column of durations. I am taking a duration constant, such as 5 minutes or 25 minutes, and multiplying it by an integer representing the number of times the process will be run, consecutively.
All these attempts resulted in Formula Parse Error:
=(5*00:05:00)
=(112*00:05:00.000)
=(VALUE(C27)*00:05:00)
=MULTIPLY(VALUE(C27),00:05:00.000)
Well, blow me down. I came up with a workaround while I was trying different ways to fail. I assigned 00:05:00 to it's own cell with the Duration format, then referenced that cell in the formula.
I.E. =C27*J7 gives me 9:20:00 when C27 equates to 112 (it's a summation of it's own) and J7 is the cell holding 00:05:00.
Still doesn't give me days when it goes over 24 hours, and I'd rather have the duration value as a constant in the formula, but it's a step forward.
Would something like this work for you?? It's no longer a number, but if it's for expressing the amount in your desired format it may be useful:
=IF(ROUNDDOWN(W2*W3),ROUNDDOWN(W2*W3)&"d "&TEXT(W2*W3-ROUNDDOWN(W2*W3),"hh:mm:ss"),TEXT(W2*W3,"hh:mm:ss"))
Change the cell references, obviously
PS: If you want to have the value as a constant in your formula, you can try to change the cell reference with TIME function within your formula:
In both Excel and Google spreadsheet, DATE are represented in a number start counting from 1899/12/30,
which...
1 is equal to 1 day
1/24 is equal to 1 hour
1/24/60 is equal to 1 minute
1/24/60/60 is equal to 1 second
you can do like:
=TODAY()+1 which gives you tomorrow, or...
=TODAY()+12/24 which gives you "date of today" 12:00:00
and when you are done with the calculations, you can simply use a TEXT() to format the NUMBER back into DATE format, such as:
=TEXT(TODAY()+7 +13/24 +15/24/60,"yyyy-mm-dd hh:mm:ss")
will return the date of a week away from today at 01:15:00 p.m.
This date/time format doesn't requires a full date to work, you can get difference of two time format like this:
=TEXT(1/24/60 - 1/24/60/60,"hh:mm:ss")
since 1/24/60 is 1 min, and 1/24/60/60 is 1 second,
this formula returns 00:00:59, telling you that there is a 59 seconds diff. between 1 min and 1 sec.

Filter rows from the last 15 minutes

I need to filter from B to K IF column A is any time in the last 15 minutes from now AND column J says "Yes"
A has the format Hour-Minute-Second, for example "17:20:59". Lets say now is 18:00:00, I want this formula to return all values from 17:45:00 until now.
For now I did this:
=FILTER(B:K, A:A=TODAY(),J:J="Yes")
I need the same but instead of today, the last 15 minutes.
How can I achieve this?
Now returns the time whereas today does not, just subtract minutes / 1440 because that is how many minutes are in a day:
=FILTER(B:K, A:A>=Now()-15/1440+n(whatthefoxsay()),J:J="Yes")

Doing hourly rate calculations for hour more than 24

I am recording my time spent on a project in google excel sheet. There is a column which does addition of the recorded time and output total time to column say D40. The output time looks like <hoursspent>:<minutesspent>:<secondsspend>. For example 30:30:50 would mean that i have worked for 30 hours and 30 minutes and 50 seconds on a project.
Now, I was using this formula to calculate my total invoice
=(C41*HOUR(D40))+(C41*((Minute(D40)/60)))+(C41*((SECOND(D40)/3600)))
Where C41 cell contains my hourly rate (say $50).
This is working fine as long as the numbers of hours that i have worked are less than 24. The moment my numer of hours go above 24. The Hour function return the modulus value i.e., HOUR(30) would return 6.
How can I make this calculation generic in a way that it oculd calculate on more than 24 hours value too.
Try
=C41*D40*24
and change formet on the result as $
one hour is part of a day, as you know 1/24th of a day, that's why you could multiply by 24 to get hours, and then multiply it by the rate
Try below formula-
=SUMPRODUCT(SPLIT(D40,":"),{C41,C41/60,C41/3600})
When you store a value as HH:mm:ss into an Excel sheet, it automatically formats it as a Time, so it makes sense that HOUR modulos by 24.
Which is why you can simply ignore it. If you have a cell that is formatted as currency (FORMAT > Math > Currency) or any other normal Number-like format, then you can see, if you perform a numerical operation like multiplication, that it stores times like "30:30:50" as if it were a TIMEVALUE with a value over 1. Simply multiply that by 24, and then by your hourly rate, and you'll get your value, i.e,
=D40 * C41 * 24 :
Just replace HOUR(D40) with INT(D40)*24+HOUR(D40)

Google sheets duration to seconds

I have a cell formatted as a duration (6:49:00)
I want to convert that to an Integer of total seconds
This formula gives me the right number of seconds =C3*60
409:00:00 <-- But I want this as just 409
To convert duration to an integer expressing the number of seconds, use a formula such as
=value(A1*24*3600)
Time values are recorded so that 1 is one day. Multiplying by 24 (hours/day) and 3600 (seconds/hour) converts that to seconds. Then value makes it a number rather than duration.
Old answer, about formatting only.
You don't need any formulas to format duration as the number of seconds.
Go to Format > Number > More formats > More data and time formats
Delete the pre-filled format fields and add "Elapsed seconds" from the dropdown menu.
I have found this solution:
let the cell A1 filled with duration like 1:22:33, than formula
=HOUR(A1)*3600+MINUTE(A1)*60+SECOND(A1)
will do the trick.
For example, 1:01:01 -> 3661
=HOUR(A1) will NOT work if your hours in the duration is > 24 of course. So the last example is not correct.
What will work is the following.
Given: A duration in hours and minutes. eg 225:04 or 9:20 or 62:35
Format must be set as this (Elapsed hours:minutes)
=INDEX(SPLIT(A1, ":"), 0, 1)*60 + INDEX(SPLIT(A1, ":"), 0, 2)

Resources