Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

how to refer to today's date in M query

Hi, 

I have found a custom query which will calculate no. of work days between days. The query works when I manually input dates in the function, however, I couldn't figure out how to use today's date in the query. Below is the function I created, clearly there is some syntax error in it. 

 

workdays.PNG

 

Thanks!

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , not completely sure. But try removing  #date and related pranthesis on second argument.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
PhilipTreacy
Super User
Super User

@Anonymous 

Try this

= Query1(#date(2021, 2, 15), DateTime.LocalNow())

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Thanks Phil. You are almost there. Still need to wrap DateTime.LocalNow() with DateTime.Date to get the correct format. 

 

amitchandak
Super User
Super User

@Anonymous , not completely sure. But try removing  #date and related pranthesis on second argument.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thank you so much, it works now. So what does #date() mean here? A query?

 

Jean

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors