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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
hdhillon
Advocate III
Advocate III

Custom Column If statement using todays date + 60 days

Hi All,

 

Im trying to create a custom column which looks to see if an existing column is less the todays date + 60 days and will return text in new column saying "over" or "under"

 

I wrote the following and I get an error:  Need your help please -->

 

if [Valid until] < DateTime.LocalNow() then "under" else "over"

1 ACCEPTED SOLUTION
hdhillon
Advocate III
Advocate III

Actually was able to solve it my self.  Using the following:

 

if [Valid until] < Date.AddDays(Date.From(DateTime.LocalNow()),60) then "under" else "over"

View solution in original post

5 REPLIES 5
sevenhills
Super User
Super User

Interesting that you are saying that you solved yourself ... good for you~

hdhillon
Advocate III
Advocate III

Actually was able to solve it my self.  Using the following:

 

if [Valid until] < Date.AddDays(Date.From(DateTime.LocalNow()),60) then "under" else "over"

sevenhills
Super User
Super User

 

Date.AddDays(Date.From(DateTime.LocalNow()), 60)

 

The syntax is for M query 

 

hdhillon
Advocate III
Advocate III

How do I write the same equation but with todays date + 60 days.  I just tried this but get an error

 

if [Valid until] < Date.From(DateTime.LocalNow()) +60 then "under" else "over"

 

(Note Valid until is a date)

 

sevenhills
Super User
Super User

Assuming "Valid until" is a date data type field, try this ... 

Date.From(DateTime.LocalNow())

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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