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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
mterry
Helper V
Helper V

Trouble comparing dates with todays date

I'm having an issue when trying to create a custom column that needs to compare an action date with todays date. The cause of the issue has been narrowed down to the below, and I'm not sure why what I've pasted doesn't work?

 

if [Action Date] < DateTime.LocalNow() then "something" else "other"

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @mterry,

 

I guess the data type of [Action Date] is date, while DateTime.LocalNow() returns datetime, which leads to unmatched error.

 

Please modify your code as below:

=if [Date] < DateTime.Date(DateTime.LocalNow()) then "something" else "other"

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @mterry,

 

I guess the data type of [Action Date] is date, while DateTime.LocalNow() returns datetime, which leads to unmatched error.

 

Please modify your code as below:

=if [Date] < DateTime.Date(DateTime.LocalNow()) then "something" else "other"

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

That worked, thank you

Ashish_Mathur
Super User
Super User

Hi,

 

Your formula works fine for me.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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