NicoWheat
NicoWheat

Reputation: 2441

Better way to calculate time between two datetimes in Google Sheets?

I wrote a formula that calculates the time difference between two datetime cells in Google Sheets.

Here is the formula for the time difference in minutes.

=(HOUR(B2)-HOUR(A2)+DAYS(B2,A2)*24)*60 + MINUTE(B2)-MINUTE(A2)

where A2 is the start datetime, and B2 is the end datetime.

start end times

I feel like Google Sheets should have a simpler method of calculating time differences, but I can't find out what function to use. Does google sheets convert to and from unix timestamps, for example? Is there a better way?

Upvotes: 1

Views: 3022

Answers (2)

player0
player0

Reputation: 1

use in row 2:

=INDEX(IFERROR(1/(1/(ROUND(24*(B2:B-A2:A), 2)))))

=INDEX(IFERROR(1/(1/(ROUND(1440*(B2:B-A2:A), 2)))))

enter image description here

Upvotes: 1

Mike Steelson
Mike Steelson

Reputation: 15308

In hours

=24*(B2-A2)

in minutes

=24*60*(B2-A2)

Upvotes: 4

Related Questions