Forum Discussion

hdhillon's avatar
hdhillon
Advocate III
4 years ago
Solved

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"

  • 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"

5 Replies

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

    Date.From(DateTime.LocalNow())

  • 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)

     

  •  

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

     

    The syntax is for M query 

     

  • 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"

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