Google Sheets’ HOUR function is a straightforward way to extract the hour part from a datetime value, saving time in calculations like scheduling, reporting, or time-based analytics. The function works with timestamps entered as dates (e.g., `MM/DD/YYYY`) or formatted as `HH:MM:SS`. No extra tools or apps are needed—just the right syntax.
What You'll Need
- A Google Sheets spreadsheet (Google Drive account required).
- Knowledge of basic datetime formats (e.g., `1:30 PM` or `2023-11-15 3:45 PM`).
- Google Sheets itself (desktop or mobile).
Step-by-Step
- Enter a datetime value in a cell (e.g., `=A1` with `11/05/2024 14:30`). If your data isn’t formatted as datetime, use
TEXTorDATEfunctions first:
This converts a plain text string (like "May 5, 2024, 3:30 PM") into a proper datetime. Save the result to a new cell.=TEXT(A1, "mmm dd yyyy hh:mm:ss") - Apply the HOUR function to extract just the hour:
For example, if `B1` holds `11/05/2024 14:30`, the result will be `14` (2 PM). Validate the input with=HOUR(B1)DATEorTODAY()to avoid errors. - Use relative cell references if needed. Drag the formula down to apply it to a range (e.g., `=HOUR(A2:A10)`).
- Handle time zones if your data spans multiple time zones. Use
TIMEZONEfirst to adjust:=HOUR(DATE(D1, TIMEZONE(D1, "America/New_York"), TIME(D1, TIMEZONE(D1, "America/New_York"))))This extracts the hour from a datetime offset to a specific timezone (e.g., New York time).
Common Mistakes
- Non-datetime input: The HOUR function only works with actual timestamps. If you pass a string like `"3 PM"` or a number, you’ll get an error. Fix it by using
DATEorTEXTto convert the input. - Leading zeros ignored: `HOUR` returns whole hours (e.g., `14` for 2:00 PM). To preserve minutes/hours, combine with
TIMEorHOUR(CEILING(TIME(A1), 15))for 15-minute blocks. - Incorrect time zones: Mixing UTC offsets or regional formats breaks results. Always normalize data before applying HOUR.
Tips
- Standardize formats for consistency. Use a helper column to format dates as `MM/DD/YYYY HH:MM` (e.g., `=TEXT(A1, "mm/dd/yyyy hh:mm")`).
- Use array formulas for bulk processing:
This extracts hours across a column while accounting for London time.=ARRAYFORMULA(HOUR(DATE(A2:A10, TIMEZONE(A2:A10, "Europe/London"), TIME(A2:A10, TIMEZONE(A2:A10, "Europe/London"))))) - Combine with other functions for granular reports. Pair HOUR with
MINUTE,SECOND, orDAYto filter data by hour/day. - Test with edge cases: Try midnight (`00`), 11:59 PM (`23`), and 12:00 AM (`00`).
Troubleshooting
- If you see a
#NUM!error:- Verify the input is a valid datetime (e.g., `11/05/2024 14:30`).
- Check for hidden characters (try pasting into a new sheet).
- Use
DATEVALUEto clean unstructured text:
For example, convert "Nov 5, 2024, 2:30 PM" to a proper number.=DATEVALUE(TEXT(A1, "mm/dd/yyyy hh:mm:ss"))
- If results are off by an hour:
- Compare the raw input (e.g., `A1`) with the formula result. Does it match expected time?
- Run `=TIMEZONE(A1)` to verify timezone alignment. If UTC is used, add a shift:
(Adds timezone offset in hours).=HOUR(A1 + TIMEZONE(A1)/1440)
- For mobile apps:
- Open Google Sheets, tap the cell, then type `=HOUR(A1)` (Google Sheets on mobile supports formula syntax).
- If using a third-party app (e.g., Kingsoft), confirm it fully supports datetime functions.
Frequently Asked Questions
How do I convert a string like "3:45 PM" into a datetime so HOUR works?
Use DATEVALUE with a custom format:
=DATEVALUE("Jan 1, " & TEXT(A1, "mm/dd/yyyy") & " " & TEXT(A1, "hh:mm:ss"), "mm/dd/yyyy hh:mm:ss")
This assumes the string follows "Month Day, Year Hour:Minute AM/PM" format. For more flexible parsing, use a helper column to extract components.
Can HOUR extract hours from a 24-hour format (e.g., 14:30)?
Yes. If your data is strictly 24-hour (e.g., `14:30`), no conversion is needed. Just reference the cell:
=HOUR(A1)
Results will be 14 (2 PM).
What if my data starts at 12:00 AM instead of 00:00?
The HOUR function treats 12:00 AM as `00` (midnight), not `12`. To handle 12-hour formats, use:
=IF(A1<>"12:00 AM", HOUR(A1), 24)
This returns 24 for noon, preserving the 12-hour convention.
How do I apply HOUR to multiple cells in a row?
Use an array formula:
=ARRAYFORMULA(HOUR(DATE(A2:A10, TIMEZONE(A2:A10, "UTC"), TIME(A2:A10, TIMEZONE(A2:A10, "UTC")))))
Adjust the range (A2:A10) and timezone to match your data. This works in desktop Sheets; mobile may require copying/pasting the formula.
Is there a way to get the hour without converting to a full datetime?
Not directly. The HOUR function requires a datetime input. Workarounds include:
- Extract the hour from a string (e.g., `"14:30"` → `14`) using regex or TEXTSPLIT:
=TEXTSPLIT("14:30", ":")[1]
This returns `14` but requires manual parsing.
Why does HOUR return 24 for 12:00 PM instead of 12?
Google Sheets uses 24-hour clock internally. To mimic 12-hour mode, use:
=IF(HOUR(A1) = 0, 12, HOUR(A1))
This returns `12` for 12:00 PM (e.g., 12 PM) and 24 for 12:00 AM (midnight).