Forum Discussion
Date is NOT within previous N months
- 4 years ago
DataFormat.Error - The dates were for USA (mdy) format. I think your date format is different is dmy, that is why this error as there is no 21 month. However, let's forget this.
Right syntax is
each not Date.IsInPreviousNYears([DATE COLUMN], 2))
Note that Date.IsInPreviousNYears excludes current year. So if current year is 2022, it will exclude only 2021 and 2020. But will include 2019, 2018 and ALSO 2022. And also if future year dates are there, they will be included.
- 4 years ago
perfect, thank you very much
one last question if i may?
What is the correct syntax to identify dates that are eaxctly 2 years prior to todays date ?
Im assuming to make it dynamic you use the DateTime.LocalNow()) syntax but how can i use the date filters to extract only the date exactly 2 years from today
- 4 years ago
See this for 2 years before date
Date.AddYears(Date.From(DateTime.FixedLocalNow()),-2)
Hence
each [DATE COLUMN] = Date.AddYears(Date.From(DateTime.FixedLocalNow()),-2)
perfect, thank you very much
one last question if i may?
What is the correct syntax to identify dates that are eaxctly 2 years prior to todays date ?
Im assuming to make it dynamic you use the DateTime.LocalNow()) syntax but how can i use the date filters to extract only the date exactly 2 years from today
See this for 2 years before date
Date.AddYears(Date.From(DateTime.FixedLocalNow()),-2)
Hence
each [DATE COLUMN] = Date.AddYears(Date.From(DateTime.FixedLocalNow()),-2)