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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Tob_P
Helper V
Helper V

Identify if today's date is between 2 dates

Hi.

 

I have created a column in Query Editor for today's date...

 

= Table.AddColumn(#"Added Custom", "Today's Date", each DateTime.LocalNow() as datetime)

 

From that I would like to identify if Today's date is between 2 dates 'Agreement Start Date' and 'Agreement End Date'. I've tried two different solutions both with errors. All Date columns are set to Date.

 

Failed Attempt 1...

 

= Table.AddColumn(#"Changed Agreement Start/End dates from date/time to date", "Custom 2", each if Date.From([#"Today's Date"]) >= Date.From([Agreement Start Date]) and Date.From[#"Today's Date"] <= Date.From([Agreement End Date]) then "Active" else "Inactive")

 

Error = Expression.Error: We cannot apply field access to the type Function.
Details:
Value=[Function]
Key=Today's Date

 

Failed Attempt 2..

 

= Table.AddColumn(Custom1, "Custom3", each if Date.Day([Agreement Start Date]) <= [#"Today's Date"] and Date.Day([Agreement End Date]) >= [#"Today's Date"] then "Active" else "Inactive")

 

Error  = Expression.Error: We cannot apply operator < to types Date and Number.
Details:
Operator=<
Left=20/03/2024
Right=1

 

Could anyone recommend a potential solution please?

 

Thanks

 

1 ACCEPTED SOLUTION
slorin
Super User
Super User

Hi

 

Attempt 1...

Date.From([#"Today's Date"])

 

= Table.AddColumn(#"Changed Agreement Start/End dates from date/time to date", "Custom 2",
each if Date.From([#"Today's Date"]) >= Date.From([Agreement Start Date]) and
Date.From([#"Today's Date"]) <= Date.From([Agreement End Date]) then "Active" else "Inactive")

 

Stéphane

View solution in original post

3 REPLIES 3
Tob_P
Helper V
Helper V

Thanks!

If you want to overcomplicate things you can also use List.Intersect

slorin
Super User
Super User

Hi

 

Attempt 1...

Date.From([#"Today's Date"])

 

= Table.AddColumn(#"Changed Agreement Start/End dates from date/time to date", "Custom 2",
each if Date.From([#"Today's Date"]) >= Date.From([Agreement Start Date]) and
Date.From([#"Today's Date"]) <= Date.From([Agreement End Date]) then "Active" else "Inactive")

 

Stéphane

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors