Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Oct 27, 2022 11:02 PM
Help please! I want to create a formula that spits out the total amount of hours work less a break time for team time sheets. I’m using time and date field to record when people work and a duration field for breaks. Can anyone give me the formula to use please?
Oct 29, 2022 06:26 AM
The duration field holds its value in “seconds” under the hood. So a duration field displaying 1 hour (1:00
) is actually holding the numerical value of 3600
.
So you could subtract your “Break” field from your “Hours” field, as hours, like this:
IF({Hours}, {Hours}, 0) - (IF({Break}, {Break} / 3600, 0))
Nov 03, 2022 06:46 PM
Thanks so much. Sadly this formula just spits out the same as the hours.
Nov 03, 2022 06:47 PM
If someone works 8 hours and takes a 30 minute break, what is the formula to get 7.5 hours please?
Nov 03, 2022 07:21 PM
Hi @Hayley_Devlin,
Is your Billable Hours
field configured to display its value as an “Integer”? It needs to be configured to display as "Decimal, or else it is going to round 7.5
up to the nearest integer, which is 8
.
Nov 03, 2022 10:06 PM
that’s it. Thank you!
Now my issue is that the hours column is not displaying half hour blocks. This should be 4.5 hours (instead of 4). Could you please tell me if this formula is right?
Nov 04, 2022 02:21 PM
What is the minimum increment you want to round to for your Hours
field? If someone works 7 hours and 15 minutes, do you want it to record 7.25
hours? Or should that round up to 7.5
hours? And what are your rounding cutoffs? Should 8:00am - 1:45pm round up to 6 hours? Or down to 5.5 hours? What about 8:00am - 1:44pm?
If rounding is no issue (maybe you will just always enter “rounded” times like 2:00 instead of 1:45), then you can just change that formula to return its difference in minutes, and then divide by 60:
DATETIME_DIFF({Finish}, {Start}, "minutes") / 60
That will get you fractions of an hour.
If rounding at thresholds is important, that will take a bit more work.
If you need to always round down until the next half-hour increment is met, FLOOR()
should do the trick:
FLOOR(
DATETIME_DIFF({Finish}, {Start}, "minutes") / 60,
0.5
)
FLOOR() rounding 7 hours and 59 minutes down to 7.5 hours worked
If you want to round to the nearest half-hour, with 15-minute cutoff thresholds, this will do it:
IF(
MOD(DATETIME_DIFF({Finish}, {Start}, "minutes"), 60) >= 45,
CEILING(DATETIME_DIFF({Finish}, {Start}, "minutes") / 60, 0.5),
IF(
MOD(DATETIME_DIFF({Finish}, {Start}, "minutes"), 60) >= 30,
FLOOR(DATETIME_DIFF({Finish}, {Start}, "minutes") / 60, 0.5),
IF(
MOD(DATETIME_DIFF({Finish}, {Start}, "minutes"), 60) >= 15,
CEILING(DATETIME_DIFF({Finish}, {Start}, "minutes") / 60, 0.5),
FLOOR(DATETIME_DIFF({Finish}, {Start}, "minutes") / 60, 0.5)
)
)
)
The formula above creates thresholds at the 15 minute marks for rounding up or down to the nearest half-hour