The DateTime.LocalNow function in Power Query returns the current date and time from your computer’s clock. It’s the Power Query version of Excel’s NOW function, and you’ll use it whenever a query needs to know what “today” or “right now” is.
The displayed result updates when Power Query reevaluates the query. If you call DateTime.LocalNow more than once in that evaluation, the calls can return different times.
In this article, I’ll show you how to use it with practical examples, including a refresh timestamp, the days left until a due date, and someone’s age from their date of birth.
Follow along with the example file
DateTime.LocalNow Function Examples.xlsx
DateTime.LocalNow Function Syntax
DateTime.LocalNow() as datetime
The function takes no arguments. You still need the empty parentheses, because without them you get the function itself instead of its result.
What it returns: A datetime value with the current date and time on the system running the query, such as 11/23/2026 4:27:54 PM.
In Excel and Power BI Desktop, that’s your computer’s local time. Microsoft’s documentation notes that Power Query Online (the Power BI service, dataflows) runs on cloud machines set to UTC, so there you get the UTC time instead.
The DateTime.LocalNow function is part of the core Power Query M library, so it works wherever Power Query does, including Excel 365, 2024, 2021, 2019, 2016, and Power BI.
When to Use the DateTime.LocalNow Function
Use this function when you need to:
- Get today’s date or the current time inside a query
- Stamp a table with the date and time it was last refreshed
- Compare dates against today, such as flagging expired or overdue items
- Count the days left until a due date
- Calculate someone’s age from their date of birth
- Build a list of dates that grows every day, such as month-to-date dates
Example 1: Get the Current Date and Time
Let’s start with the basics and see what the function returns on its own.
In Excel, go to Data > Get Data > From Other Sources > Blank Query. In the Power Query Editor that opens, type this formula in the formula bar:
= DateTime.LocalNow()
Result: The current date and time, for example 2026-11-23T16:27:54.7588434

Here, the function reads your computer’s clock and returns the date and the time together as one datetime value. Your result will show the date and time when you ran it, so it won’t match mine.
The preview shows a single datetime value in this ISO layout, with the year first and the time down to fractions of a second. In a table column, as in Example 3, the same kind of value shows in your regional date format, like 11/23/2026 4:27:55 PM.
That table format follows your computer’s regional settings, so a computer with UK settings would show the same moment as 23/11/2026 16:27:55.
To get a newer value, refresh the preview (Home > Refresh Preview) or refresh the query in Excel. The value doesn’t change while the query just sits there.
In the example file, Examples 1, 2, 4, and 8 have no sheet because they don’t use any data. You can open them from Data > Queries & Connections.
Example 2: Get Today’s Date Without the Time
Most of the time, you only want today’s date, not the time. The DateTime.LocalNow function always returns both, so you need to strip off the time part.
In the Power Query Editor, create a new blank query (Home > New Source > Other Sources > Blank Query) and use this formula:
= Date.From(DateTime.LocalNow())
Result: Today’s date, for example 11/23/2026

Here, the Date.From function takes the datetime and keeps only its date part. So the result is a date value, which is the M version of Excel’s TODAY function.
DateTime.Date(DateTime.LocalNow()) gives you the same date. And if you only want the time, DateTime.Time(DateTime.LocalNow()) keeps the time part instead.
This date-only version matters a lot when you compare against date columns, which you’ll see in Example 5. For a full walkthrough of today’s date in Power Query, see how to get today’s date in Power Query.
Example 3: Add a Last Refreshed Column to a Table
Here’s a common use case. When you share a report that pulls data with Power Query, it helps to show when the data was last refreshed.
Below is an orders table, and I want to add a Refreshed On column with the date and time of the refresh.

Create a new blank query, open the Advanced Editor (Home > Advanced Editor), and use this code. It reads the Orders table by name, so you don’t have to load it into Power Query first.
let
Source = Excel.CurrentWorkbook(){[Name="Orders"]}[Content],
RefreshTime = DateTime.LocalNow(),
#"Added Refreshed On" = Table.AddColumn(Source,"Refreshed On",each RefreshTime,type datetime)
in
#"Added Refreshed On"
Result: A new Refreshed On column with the same date and time in every row, for example 11/23/2026 4:27:55 PM

Here, the RefreshTime step calls DateTime.LocalNow once and stores the result. Then Table.AddColumn puts that stored value in every row, and type datetime sets the column type.
I put the function in its own step on purpose. Microsoft’s documentation says DateTime.LocalNow may return different values while a query runs, so calling it inside each could, in theory, give rows a few milliseconds apart.
A step is worked out once, so every row gets the exact same timestamp. The DateTime.FixedLocalNow function is the other way to get one value for the whole refresh.
When you load this to a worksheet, the Refreshed On column updates every time you click Data > Refresh All.
Example 4: Create a Last Refreshed Label
Sometimes you don’t want a whole column. You just want one line of text, like “Last refreshed: Nov 23, 2026 4:27 PM”, that you can load into a cell above a report.
Create a new blank query and use this formula:
= "Last refreshed: " & DateTime.ToText(DateTime.LocalNow(),[Format="MMM d, yyyy h:mm tt"])
Result: A text label with the refresh time, for example Last refreshed: Nov 23, 2026 4:27 PM

Here, the DateTime.ToText function turns the datetime into text using the format code MMM d, yyyy h:mm tt. That gives a short month name, the day, the year, and a 12-hour time with AM or PM.
The & operator then joins that text to “Last refreshed: “. You need DateTime.ToText here because & can’t join text and a datetime directly.
You can change the format code to suit your report. For example, yyyy-MM-dd HH:mm gives 2026-11-23 16:27 with a 24-hour time.
Follow along with the example file
DateTime.LocalNow Function Examples.xlsx
Example 5: Flag Expired and Active Warranties
Now let’s compare a date column against today. Below is a list of office equipment with the date each warranty ends, and I want a Status column that says Expired or Active.

Create a new blank query, open the Advanced Editor, and use this code:
let
Source = Excel.CurrentWorkbook(){[Name="Equipment"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Warranty End",type date}}),
Today = Date.From(DateTime.LocalNow()),
#"Added Status" = Table.AddColumn(#"Changed Type","Status",each if [Warranty End] < Today then "Expired" else "Active",type text)
in
#"Added Status"
Result: Expired for Laser Printer, Projector, and Label Maker, and Active for Office Router, Conference Phone, and Backup UPS

Here, the Changed Type step makes sure Power Query treats Warranty End as dates, and the Today step stores today’s date once. Then the Status column checks each row, and if the warranty end date is before today, it returns “Expired”, otherwise “Active”.
Note the Date.From part of the Today step. The Warranty End column holds dates, while DateTime.LocalNow returns a datetime, and Power Query won’t compare those two types.
Important: If you compare with DateTime.LocalNow() directly, without Date.From, every Status cell shows an error: “We cannot apply operator < to types DateTime and Date.” Wrap DateTime.LocalNow in Date.From so both sides are dates.
Because the warranty dates here are years in the past or future, you’ll see the same Expired and Active labels when you refresh. With your own data, a row moves from Active to Expired on the day after its warranty ends.
Example 6: Count the Days Left Until a Due Date
This next one comes up a lot with invoices, tasks, and deadlines. Below is a list of invoices with their due dates, and I want a Days Left column that shows how many days are left until each one is due.

Create a new blank query, open the Advanced Editor, and use this code:
let
Source = Excel.CurrentWorkbook(){[Name="Invoices"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Due Date",type date}}),
Today = Date.From(DateTime.LocalNow()),
#"Added Days Left" = Table.AddColumn(#"Changed Type","Days Left",each Duration.Days([Due Date] - Today),Int64.Type)
in
#"Added Days Left"
Result: On November 23, 2026, the Days Left column shows -26, -13, -3, 7, 22, and 43

Here, the Today step holds today’s date, the same way as in Example 5. Subtracting it from the due date gives a duration, which is Power Query’s way of storing a length of time.
The Duration.Days function then pulls the number of days out of that duration as a whole number.
A positive number is the days left before the due date. A negative number means the invoice is overdue, so INV-2207 at -26 is 26 days past due.
Since the formula uses today’s date, these numbers go down by one every day. When you refresh the example file, you’ll see different values than mine, and that’s expected.
For more ways to subtract dates, see how to calculate date difference in Power Query.
Example 7: Calculate Age in Years from a Date of Birth
Calculating age is a classic job for DateTime.LocalNow, and it’s a bit trickier than it looks. Below is a member list with each person’s date of birth, and I want their current age in years in an Age column.

Create a new blank query, open the Advanced Editor, and use this code:
let
Source = Excel.CurrentWorkbook(){[Name="Members"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date of Birth",type date}}),
Today = Date.From(DateTime.LocalNow()),
#"Added Age" = Table.AddColumn(#"Changed Type","Age",each Date.Year(Today) - Date.Year([Date of Birth]) - (if Date.AddYears([Date of Birth],Date.Year(Today) - Date.Year([Date of Birth])) > Today then 1 else 0),Int64.Type)
in
#"Added Age"
Result: On November 23, 2026, the ages are 36, 40, 25, 48, 29, and 57

Here, the Today step stores today’s date once, so the formula can use it several times. The formula first subtracts the birth year from the current year, which gives the age the person turns this year.
Then it checks whether this year’s birthday is still ahead. Date.AddYears moves the date of birth forward to this year, and if that date is after today, the formula takes 1 off.
That’s why Jill Rogers shows 40, not 41. Her birthday is on November 30, so she hasn’t turned 41 yet.
Howard Anderson’s birthday is today (November 23), so his age already shows 25.
You might see a shortcut that divides the number of days by 365.25 and rounds down. It’s often right, but it can be a year off around a birthday.
For Howard, that shortcut returns 24 instead of 25, so I prefer the formula above.
Example 8: Create a List of Month-to-Date Dates
Here’s one more use that builds on today’s date. Suppose you want a list of every date from the first of the current month up to today, for a month-to-date report.
Create a new blank query, open the Advanced Editor, and use this code:
let
Today = Date.From(DateTime.LocalNow()),
Dates = List.Dates(Date.StartOfMonth(Today),Date.Day(Today),#duration(1,0,0,0))
in
Dates
Result: On November 23, 2026, a list of 23 dates from 11/1/2026 to 11/23/2026

Here, Date.StartOfMonth(Today) gives the first day of the current month, which is where the list starts. Date.Day(Today) returns 23, the day number of today, so that’s how many dates the list gets.
The List.Dates function then creates the dates, one day apart, because #duration(1,0,0,0) is a step of one day. Tomorrow the list will have 24 dates, and on the first of next month it starts over with just one.
To use the list as a table (for example, as a small calendar), click To Table on the List Tools tab in the Power Query Editor.
Other Excel Articles You May Also Like:
- Date.AddMonths
- Date.EndOfMonth – Use Date.EndOfMonth in Power Query M to get the last day of a month.
- Date.Year – Use Date.Year in Power Query M to extract the year from a date.
- Date.Month – Use Date.Month in Power Query M to get the month number from a date.
- Date.ToText – Use Date.ToText in Power Query M to convert dates to text.
- Date.AddDays – Use Date.AddDays in Power Query M to add or subtract days from a date.
- Date.EndOfWeek – Use Date.EndOfWeek in Power Query M to get the last day of a week.
- Date.StartOfWeek – Use Date.StartOfWeek in Power Query M to get the first day of a week.