Forum Discussion
Date column last x months
Hello everyone,
I have created a calculated column which filters the most recent months, in this particular example the last two months. This filter was working, but only in the year itself. Now we are in the new year, it shows only the month of this year, but it still want the months of 2021. So I want all the dates from 1 November till today (so the 4th of January).
The formula is as follows:
- Anonymous4 years ago
Thank you amitchandak for your (fast) reply π
The results I got were alle blanks, so I adjusted the formula as follows:
Last 2 months = IF(OR(OR(EOMONTH([Date], 0) =EOMONTH(TODAY(), 0), EOMONTH([Date], 0) = EOMONTH(TODAY(), -1)), EOMONTH([Date], 0) = EOMONTH(TODAY(), -2)), "Laatste 2 maanden", BLANK())This resulted in the desired outcome.
2 Replies
- amitchandak
Super User
Anonymous , better to use EOmonth to deal with months
check one of three should work
Last 2 months = IF(eomonth([Date],0)=eoMonth(Today(),-3)+1 && [Date] <=TODAY(), "Last 2 months", BLANK())
or
Last 2 months = IF(eomonth([Date],0)=eoMonth(Today(),-3)+1 && eomonth([Date],0) <=eomonth(TODAY(),0), "Last 2 months", BLANK())
or
Last 2 months = IF(eomonth([Date],0)=eoMonth(Today(),-3)+1 && eomonth([Date],0) <=eomonth(TODAY(),-1), "Last 2 months", BLANK())
- AnonymousNot applicable
Thank you amitchandak for your (fast) reply π
The results I got were alle blanks, so I adjusted the formula as follows:
Last 2 months = IF(OR(OR(EOMONTH([Date], 0) =EOMONTH(TODAY(), 0), EOMONTH([Date], 0) = EOMONTH(TODAY(), -1)), EOMONTH([Date], 0) = EOMONTH(TODAY(), -2)), "Laatste 2 maanden", BLANK())This resulted in the desired outcome.