HomeGoogle DocsSpreadsheetHow to Check Time Input in a Range of Cells in Google...

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.

Creating Sequential Dates in Equally Merged Cells in Google Sheets

Do you know how to create sequential dates in equally merged cells across a...

Running Total By Month in Excel

This tutorial demonstrates how to calculate the running total by month in a range...

SORT and SORTBY – Excel Vs Google Sheets

While Excel offers the SORT and SORTBY functions for sorting a table, Google Sheets...

Get Top N Values Using Excel’s FILTER Function

When using the FILTER function in Excel to extract the top N values, it's...

More like this

Creating Sequential Dates in Equally Merged Cells in Google Sheets

Do you know how to create sequential dates in equally merged cells across a...

Interactive Random Task Assigner in Google Sheets

You have multiple tasks and multiple people. Here's a fun way to randomly assign...

Google Sheets Bar and Column Chart with Target Coloring

To color each data point in the column or bar chart according to the...

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.