In Power Query, if you want to get today’s date (current date in a column), you need to add a custom column by using two functions together.
Note: Use the formula DateTime.Date( DateTime.LocalNow() ) to get today’s date using power query.
Below are some dates in the Column, and now we need to add a column with today’s date.
Steps to Add a Current Date Column
- First, go to the Data Tab > From Other Source > From Table/Range.
- Now in the power query editor, you need to add a new custom column, so go to Add Column > Custom Column.
- From here, enter the formula DateTime.Date(DateTime.LocalNow()) and give a name to the new Column in the custom column dialog box.
- In the end, click OK to add the Column.
=DateTime.Date( DateTime.LocalNow() )
How this Formula Works
In this formula, we have used two functions:
- The first function (DateTime.LocalNow) returns the current date and time according to the date and time of your system.
- The second function (DateTime.Date) wrapped around the first one gets the date part from it and returns it as a final value.
Instead of the above formula, you can use the (DateTime.LocalNow()) in the custom column.
And after that, go to the Home > Data Type and select the Date from the drop down to convert the Column into the date only.
It will convert the date and time into date only.
Adding Current Date in a Single Cell
And if you want to have the current date in a single cell, you need open the Power Query editor with a blank editor.
After that, in the editor, enter the below formula in the formula bar and hit enter.
= DateTime.Date( DateTime.LocalNow() )
After that, you can convert this date value into a table or a list.
Get the Excel FileDownload
- Back to the Excel Power Query Tutorial