How to Hardcode DateTime Criteria in Google Sheets FILTER Function

Published on

In this tutorial, you’ll learn how to hardcode DateTime criteria in Google Sheets using the FILTER function. If you’re trying to filter data based on exact timestamps (date and time), this guide will show you the right way to format and compare those values.

We’ll walk through practical examples, such as filtering employee attendance logs, to demonstrate how to hardcode DateTime values effectively inside the FILTER function.

Understanding DateTime in Google Sheets

A DateTime value, also called a timestamp, contains both date and time—e.g., 15/01/2022 10:30.

You can format these values in your spreadsheet by selecting the range and going to: Format > Number > Custom date and time

💡 This formatting affects how timestamps are displayed—but it doesn’t change how formulas interpret them internally.

Why FILTER Doesn’t Accept Timestamp Text Strings

In some functions like COUNTIF, you can use a timestamp as a text string:

=COUNTIF(A2:A, ">=16/01/2022 15:30")

But FILTER does not reliably interpret text-formatted timestamps. Instead, you should construct DateTime values using the DATE and TIME functions.

Sample Data: Employee Attendance Logs

Let’s say you’re tracking employee attendance with the following timestamped punch-in data:

Time LogsEmployee Names
15/01/2022 10:30Sara
15/01/2022 09:55Kristy
15/01/2022 10:00Ben
15/01/2022 10:11Ronnie
15/01/2022 09:45Karen
15/01/2022 09:59Tonya
16/01/2022 10:06Sara
16/01/2022 09:56Kristy
16/01/2022 09:58Ben
16/01/2022 10:00Ronnie
16/01/2022 10:01Karen
16/01/2022 10:05Tonya

Paste this data into cell range A1:B13 in your Google Sheet.

Google Sheets may misinterpret your pasted timestamps depending on your system’s locale or date format. Here’s how to confirm they’re correctly recognized:

To ensure the timestamps are recognized correctly:

  1. In a blank cell, enter: =DAY(A2)
    • If the result is 15, your date format is correct.
    • If you see an error or an unexpected number, your dates might be stored as text.
  2. To find the correct format for your spreadsheet:
    • Enter =NOW() in a blank cell.
    • Note the format of the output (e.g., 01/15/2022 10:30 or 15/01/2022 10:30).
    • Format your time log values in column A to match that style.
  3. Optional: Highlight column A, then go to Format > Number > Date time to apply a standard timestamp format.

This ensures that the FILTER function interprets the values as real DateTime data.

How to Hardcode DateTime Criteria in Google Sheets Filter Function

Example 1: Hardcoding a Full DateTime Condition

To filter rows where timestamps are after 15 January 2022, 3:30 PM, use:

=FILTER(A2:B, A2:A > DATE(2022, 1, 15) + TIME(15, 30, 0))

✅ This is the correct way to hardcode a DateTime value inside the FILTER function.

Example 2: Filter Latecomers on a Specific Day

Let’s say office time starts at 10:00 AM. To find employees who punched in after 10:05 AM on 15 January 2022, but before the next day:

=FILTER(A2:B, A2:A > DATE(2022, 1, 15) + TIME(10, 5, 0), A2:A < DATE(2022, 1, 16))

Alternative Using ISBETWEEN:

=FILTER(A2:B, ISBETWEEN(A2:A, DATE(2022, 1, 15)+TIME(10, 5, 0), DATE(2022, 1, 16), FALSE, FALSE))
Example of using hardcoded DateTime criteria in the FILTER function in Google Sheets to extract rows based on timestamp conditions

Example 3: Filter Latecomers Regardless of Date

Want to check who arrived after 10:05 AM on any day?

Use this clever trick with MOD to isolate the time part:

=FILTER(A2:B, MOD(A2:A, 1) > TIME(10, 5, 0))

Note: MOD(timestamp, 1) removes the date, keeping only the time portion.

Best Practices for Using DateTime in FILTER Function

While this tutorial focuses on hardcoding, a more flexible approach is to place the DateTime value in a cell (e.g., E1) and reference it:

=FILTER(A2:B, A2:A > E1)

This makes it easier to update criteria without editing formulas.

If you’re working with timestamps, here are more tutorials related to hardcoding DateTime criteria in Google Sheets and using them in various functions:

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Expert Prashanth KV is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Top Discussions

More like this

Pivot Table Formatting, Output & Special Behavior in Google Sheets

Pivot Tables in Google Sheets are powerful—but they can get tricky once you move...

Pivot Table Calculations & Advanced Metrics in Google Sheets

When it comes to built-in tools for data analysis and visualization in Google Sheets,...

Google Sheets Pivot Table Tutorial: Basics, Setup, and Date Grouping

The easiest way to summarize, analyze, and report data in Google Sheets is by...

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.