How to Check Time Input in a Range of Cells in Google Sheets

Published on

To check time input in a range of cells or a single cell you can use the TIMEVALUE function in Google Sheets. If it’s a range of cells the formula should be entered as an Array Formula.

We can use either of the functions ISBLANK or LEN to test whether a cell contains a value. Both will work in a range of cells (array) also.

While the former returns TRUE or FALSE Boolean values the latter returns 0 for blank and the number of characters for non-blanks.

But none of them is useful to test whether the cell not only contains a value but also that value is time.

ISBLANK and LEN in a time range

With TIMEVALUE function we can check time input in a range of cells in Google Sheets.

How to Check Time Input in a Range of Cells Using TIMEVALUE

Let’s start with a single cell.

test time input in Sheets

As you can see the TIMEVALUE formula returns #VALUE! error when the value in cell A1 changes to the text string or number. It only works with date and time.

If the value is a date, the TIMEVALUE formula would return 0. For time input, no doubt, the formula would return the value of that time.

We can use TIMEVALUE in an IF statement as below.

=if(timevalue(A1)>0,TRUE,FALSE)

The above formula would only return TRUE, when the value in cell A1 is a time. For a date input, it would return FALSE. Else for text and number entry, the formula would definitely return the VALUE! error.

Formula to Check Time Input in a Range of Cells in Google Sheets

Here is a real-life example to the use of checking time input in a range of cells in Google Sheets.

Suppose cell A2 contains the start time and B2 contains end time. I want to only do the below calculation if both the cells contain time inputs.

=B2-A2

Here is the formula that tests both the cells for time inputs and perform the above calculation.

=ArrayFormula(IF(COUNT(TIMEVALUE({A2,B2}))=2,B2-A2,""))

Logic:

The count of cell A2 and B2 will be 2 if both the values are time. Else return 1 or 0.

=ArrayFormula(COUNT(TIMEVALUE({A2,B2})))

That’s all. Hope you have enjoyed the stay!

Additional Resources:

  1. How to Filter Timestamp in Query in Google Sheets.
  2. Google Sheets: The Best Overtime Calculation Formula.
  3. COUNTIFS in a Time Range in Google Sheets [Date and Time Column].
  4. How to Convert Military Time in Google Sheets.
  5. Elapsed Days and Time Between Two Dates in Google Sheets.
Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Hierarchical Numbering Sequences in Excel

Creating hierarchical numbering sequences in an Excel spreadsheet can significantly improve the way you...

How to Easily Repeat a Sequence of Numbers in Excel

Excel offers multiple ways to accomplish tasks, and the simplicity of each approach depends...

Create a Sequence of Dates at Every Nth Row in Excel (Dynamic Array)

Would you like to create a sequence of dates in every nth row in...

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

More like this

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

Limit Formula Expansion to a Specific Row in Google Sheets

In this tutorial, I’ll explain how to limit the expansion of an array formula...

3-D Referencing Structured Data Tables in Google Sheets

When you have several tables within a single sheet—not across multiple sheets in a...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.