# How do I prevent or omit a negative value when calculating between times?

I've researched through the site to see if this has been answered but with no luck after reading:

In Google Sheet I'm trying to measure time accounting for a break:

When I add the first start time I get a negative:

when I add a clock out it's ok:

Starting the time back up it throws that time off:

How can I calculate the time that has an IN and OUT but omit the time when it only has an IN value?

The formula:

``````=ROUND((ARRAYFORMULA(IF(ISBLANK(B3:C3)=FALSE,((C3-B3)*24*60/60),""))) + ARRAYFORMULA(IF(ISBLANK(D3:E3)=FALSE,((E3-D3)*24*60/60),"")),2)
``````
• This question has been bumped by Community user 16 times. Oct 27, 2023 at 3:55

• to prevent negative value you can `MAX` it:

``````=MAX(ROUND(ARRAYFORMULA(IF(ISBLANK(B3:C3)=FALSE,((C3-B3)*24*60/60),""))
+ ARRAYFORMULA(IF(ISBLANK(D3:E3)=FALSE,((E3-D3)*24*60/60),"")),2),0)``````

• to fix the logic:

``````={IF(E3<>"",ROUND(ARRAYFORMULA(IF(ISBLANK(B3:C3)=FALSE,((C3-B3)*24*60/60),""))
+ ARRAYFORMULA(IF(ISBLANK(D3:E3)=FALSE,((E3-D3)*24*60/60),"")),2),
ROUND(ARRAYFORMULA(IF(ISBLANK(B3:C3)=FALSE,((C3-B3)*24*60/60),"")),2))}``````

Considering that Google Sheets can do additions and subtractions of date, time and durations, the formula looks to be convoluted, as shown in the question looks to be complicated.

There is no need to use `ARRAYFORMULA`, `IF`, `ROUND`, multiplication and division operations.

``````=MAX(0,C3-B3)+MAX(0,E3-D3)
``````

To set the cell formatting to Duration, do the following:

1. Click Format > Number > Duration

You might use Format > Number > Custom date and time to refine the format, i.e., remove the seconds part.