I am trying to get a formula for the month's end on any particular day (TODAY) but can't get my head around it.
Basically, end of the month is 24th, unless 25th falls on the weekend. So if the 25th is Saturday, EOM is 23rd and if it is Sunday, then 22nd.
I can build an IF structure for the date, it is not difficult:
Where B2 is TODAY(). Probably not very elegant, but it works.
However, I cannot figure out how to change a month, because the end date is different in each particular month. For example in February this year, end of the month should be 22/02/2018 up to this date and 22/03/2018 from 23/02/2018 till 22/03/2018. After that it should change to 24/04/2018. But I cannot figure out how to make the change.
Basically, end of the month is 24th, unless 25th falls on the weekend. So if the 25th is Saturday, EOM is 23rd and if it is Sunday, then 22nd.
I can build an IF structure for the date, it is not difficult:
Code:
=IF(WEEKDAY(DATE(YEAR(B2),MONTH(B2),25),2)=6,DATE(YEAR(B2),MONTH(B2),23),IF(WEEKDAY(DATE(YEAR(B2),MONTH(B2),25),2)=7,DATE(YEAR(B2),MONTH(B2),22),DATE(YEAR(B2),MONTH(B2),24)))
Where B2 is TODAY(). Probably not very elegant, but it works.
However, I cannot figure out how to change a month, because the end date is different in each particular month. For example in February this year, end of the month should be 22/02/2018 up to this date and 22/03/2018 from 23/02/2018 till 22/03/2018. After that it should change to 24/04/2018. But I cannot figure out how to make the change.