Power Query DateTime.IsInCurrentHour: How to Use It
In this article
DateTime.IsInCurrentHour is a Power Query M function that returns true or false depending on whether a given date-time value falls inside the current clock hour — that is, between the start of this hour and the start of the next. It takes a single datetime argument and evaluates against your machine's local system time at the moment the query refreshes, not against a fixed date. A typical use is a dashboard or report that should always show "this hour" (for example, today's readings so far), so rows quietly drop out of scope as time passes. All you need first is a column that is genuinely typed as Date/Time in Power Query; a text column with a date in it will error until converted.
What You'll Need
- Power BI Desktop, Excel with Power Query, or another host that runs Power Query M (Power BI Service dataflows and the data gateway behave the same for this function).
- A query that already loads a table or list containing a date-time column.
- That column converted to the Date/Time data type — check the icon in the column header; it should show a calendar with a clock, not ABC.
- Awareness that the function reads the machine's local clock, so results depend on the time zone where the refresh runs.
Step-by-Step
- Open your report in Power BI Desktop or your workbook in Excel, then open the Power Query Editor (in Power BI: Home > Transform data; in Excel: Data > Get Data > Launch Power Query Editor).
- Select the query that holds your date-time column in the Queries pane on the left.
- Click the column header of the date-time field and confirm the data type. If it shows as Text or Any, use Transform > Data Type > Date/Time to convert it. If conversion fails, some rows contain values M cannot parse — fix or filter those first.
- Go to Add Column > Custom Column. Give it a name such as InCurrentHour.
- Enter the formula in the box, replacing the column reference with your own. If your column is literally named Timestamp, write:
DateTime.IsInCurrentHour([Timestamp]) - Click OK. Each row now shows
TRUEorFALSE. M is case-sensitive for the function name:DateTime.IsInCurrentHour, with capital D, T, I, C and H, is the only form that works. - Optionally filter the new column to keep only
truerows: click the filter arrow on the new column header and clear thefalsecheckbox. Because the filter is part of the query, it re-evaluates on every refresh. - Click Close & Apply (Home tab) to load results back to the model or sheet. The values are recalculated when the query refreshes, so a scheduled refresh in the service gives you a moving "current hour" view.
If you want the flag as a conditional label instead of a boolean, wrap it: if DateTime.IsInCurrentHour([Timestamp]) then "This hour" else "Earlier". If you need to test several rows at once or filter before loading, you can also filter the column directly in the formula bar using the same expression rather than adding a helper column.
Common Mistakes
Passing a date instead of a date-time. The function expects a datetime. Pass a date and M raises Expression.Error about a type mismatch. Use DateTime.From to convert if needed, but a pure date always returns false because a date has no hour component to test.
Passing text. A quoted value such as "2026-12-05 09:15:00" is text, not a date-time, and will error. Convert the column's type first, or wrap the literal in #datetime(2026,12,5,9,15,0).
Expecting a fixed answer. People test the function, see true, save the file, and are surprised later when the value flips to false. That is correct behaviour — the comparison is against the clock at evaluation time. If you need a stable flag, store a literal timestamp and compare with DateTime.IsInCurrentHour only in a live query.
Assuming the server's time zone. When a scheduled refresh runs in the cloud, "current hour" follows the machine or service that executes it, not your laptop. Rows can appear an hour or more out of step with your local sense of "now".
Spelling and casing errors. Lowercase datetime.isincurrenthour is not recognised. IntelliSense in the formula bar helps; type DateTime. and pick from the list.
Nulls. A null date-time returns an error rather than false. Add a null check with if [Timestamp] = null then false else DateTime.IsInCurrentHour([Timestamp]) if your column contains blanks.
Tips
- Use the sibling functions for other windows:
DateTime.IsInCurrentMinute,DateTime.IsInCurrentSecond,DateTime.IsInCurrentDay,DateTime.IsInCurrentWeekandDateTime.IsInCurrentMonthfollow the same pattern, so learning one teaches the rest. - Keep the helper column visible while building; hide it or remove it once the filter or conditional logic is final to keep the model tidy.
- Refresh manually a few times across a minute boundary while testing so you can confirm the result really moves.
- Wrap the function in a measure-friendly helper if you need aggregates: filter the table in the query, then use a simple
COUNTROWSmeasure on the filtered table.
Troubleshooting
If you get an Expression.Error with "We cannot convert" wording, the column is the wrong type — set it to Date/Time and re-check. If the function is not recognised at all, suspect a typo or missing capitalisation. If every row returns false, confirm the data actually contains today's date and that the clock on the machine running the refresh is correct; a wrong system time shifts the whole window. If only some rows are true, that is expected: it means only those rows fall in the current hour, so check whether you actually meant DateTime.IsInCurrentDay. If the query is fine in Desktop but stale in the Power BI Service, the refresh schedule or the gateway time zone is the likely cause — check the dataset's refresh history and the gateway settings. If a previously working query starts erroring after an edit, look at the Applied Steps pane and step back one step to see where the type changed. Finally, remember that these time-based functions recalculate on refresh only; a report left open does not update itself as the hour rolls over unless it is refreshed.
Frequently Asked Questions
What data type does DateTime.IsInCurrentHour accept?
One datetime value. A date, text or null argument errors; convert the column first.
Why does it return true for only a handful of rows?
Because it tests against the current clock hour only. Records outside that hour are correctly false.
Does the result change without a refresh?
No. The flag is stored when the query evaluates, so it stays put until the next refresh.
Which time zone is used?
Whichever machine or cloud service executes the refresh. For scheduled refreshes, that is the service or gateway environment, not necessarily your desk.
Is there an equivalent for a specific hour I choose?
Yes — compare directly, for example Time.Hour(DateTime.Time([Timestamp])) = 9, or build a range check with #datetime literals.
Can I combine it with other filters?
Yes. Add it inside a single Table.SelectRows expression alongside your other conditions, joined with and.