So I need to create a BM to give me the previous month, I use this as a filter for a report to send people the previous month's data. I found that with the year change my current formula does not catch December if it is January. I am looking for a filter to give me the rows where Entry Date is during the previous month.
case
when MONTH(CURDATE()) = MONTH(`Entry Date`) then 'This Month'
when MONTH(CURDATE()) - 1 = MONTH(`Entry Date`) then 'Last Month'
else 'Other Month'
end
I have a similar concept that looks for the next month and I found a way to use MOD in order to capture year changes. I tried applying the same concept in order to get the previous month but I could not get it. Here was my next month BM.
case
when MONTH(`Latest Hire date`) = MOD(MONTH(CURDATE()),12) + 1 then 'Next Month'
else 'Other'
end
For now I have added this line to my BM to give me the previous month when it is Jan but does anyone have something similar to the MOD fix that will allow me to just have one line to account for all cases? I hate having to do a manual case.
when MONTH(CURDATE()) = 1 and MONTH(`Entry Date`) = 12 then 'Last Month' -- manual fix to get December after year change