Google Sheets does recognize the date-time combination. This is what I get after entering the dates you gave in A1 and B1, and entering =B1-A1
in the cell C1:
+---+---------------------+--------------------+---------------+
| | A | B | C |
+---+---------------------+--------------------+---------------+
| 1 | 10/27/2015 23:38:00 | 10/28/2015 1:38:00 | 0.08333333334 |
+---+---------------------+--------------------+---------------+
No error; the output is expected: the difference is 0.08333.. of the day, i.e., 2 hours. The column C should be formatted as Duration to make the output user friendly.
Then I tested addition; it also works as expected, with C4
being SUM(C1:C3)
.
+---+---------------------+--------------------+----------+
| | A | B | C |
+---+---------------------+--------------------+----------+
| 1 | 10/27/2015 23:38:00 | 10/28/2015 1:38:00 | 2:00:00 |
| 2 | 10/27/2015 15:38:00 | 10/28/2015 4:38:00 | 13:00:00 |
| 3 | 10/27/2015 14:38:00 | 10/28/2015 2:38:00 | 12:00:00 |
| 4 | | | 27:00:00 |
+---+---------------------+--------------------+----------+
Conclusion: something went wrong at the stage of entering data in your sheet. Check whether 10/27/2015
is recognized (autoformatted as date) when you enter it in a cell. This behavior depends on your locale setting.
On Google Sheets, a duration of 13 minutes and 1 second is shown in the formula bar as follow
00:13:01.000
To display the above value as 13:01, apply a custom format by clicking on Format > More formats... then apply the following mm":"ss
By the other side, Google Sheets formulas doesn't allow to write date, time and duration values directly. The alternatives are
- Write the date/time/duration in a cell and use a reference to that cell in the formula
IF(AND(I3<A1,J3>49,K3>49,L3>5,M3<A2),"P","F")
- Use a function that returns the corresponding date, time or duration. The following example use TIMEVALUE
IF(AND(I3<TIMEVALUE("0:13:01"),J3>49,K3>49,L3>5,M3<TIMEVALUE("0:12:01")),"P","F")
- Write the serialized number corresponding to the date, time or duration. In the following example 13 minutes and 1 second is
0.009039351852
and 12 minutes and 1 second is 0.008344907407
IF(AND(I3<0.009039351852,J3>49,K3>49,L3>5,M3<0.008344907407),"P","F")
Best Answer
Try this:
This is a bit simpler than
large()
, and has the benefit that the result cell gets formatted automatically. But it actually gives the exact same result — your existing formula is also correct. To see the "decimal" result as a time, format the cell as Format > Number > Time.How do date and time values work in spreadsheets?
Hope the following helps you understand what is going on with dates and times.
Google Sheets datetimes and durations are stored as numbers that correspond to the number of days since the start of "the Epoch", i.e.,
30 December 1899
. The fractional part corresponds to the fraction of the day. When a cell is formatted as a date, time or duration, the number is simply shown in years, months, days, hours, minutes and/or seconds, but its underlying value remains unchanged.In other words, all date, datetime, time and duration values are just numbers formatted as such — the date
2020-04-17
is43938
, the datetime2020-04-17 12:00 noon
is43938.5
, the time12:00 noon
is0.5
, and the duration06:00
is0.25
. The value1
corresponds to one day, i.e., 24 hours.Since the datetime value tells the number of days, you can increment a date by one day simply by adding 1, as in
=A2 + 1
. You can compare two dates the same way you would compare two numbers, as in=A2 < B2
. You can add a duration to a date or a datetime to get a datetime, and subtract one datetime from another to get a duration.One hour is 1/24 of a day, so to multiply an hourly rate such as $30/h by a duration, use
=(24 * R2) * D2
where cellR2
contains the hourly rate and cellD2
contains the duration.One minute is 1/24/60 of a day, so to multiply a revolutions per minute number such as 3000 rpm by a duration to get the total number of revolutions, use
=(24 * 60 * R2) * D2
.One second is 1/24/60/60 of a day, so to multiply a speed given in meters per second such as 10 m/s by a duration to get a distance in meters, use
=(24 * 60 * 60 * R2) * D2
.Note how these formulas do not convert the time value. It remains a dateserial value that expresses a fraction of the day. The value that is converted is the rate — it is multiplied to get rate per day from rate per hour, rate per minute or rate per second.
I find it easiest to always work with time and date using the built-in datetime number formats because that way you never have trouble with time values that exceed 24 hours, date values that exceed 365 days, and do not need to take leap years and such into account — all those details are automatically taken care of by the spreadsheet's built-in functionality if you just stick to formatting all date and time cells as dates and times, and use regular arithmetic to add and subtract them.
One often sees formulas that multiply a time value by 24 to get "digital hours" where
10.50
does not mean ten hours 50 minutes but ten and a half hours. This convention frequently causes misunderstandings, and also makes it harder, not easier, to use the value in further processing. For example, a "digital hour" value cannot be directly added to a date to get a datetime.That is why I prefer using the built-in time formats that express the same as
10:30
. This time value can be directly added to a date to get a datetime.