Forum Discussion
Determine if a date belongs in a certain month
- Nov 17, 2021
BigDaveB That could be:
=IF(DAY(A2)>=28,EOMONTH(A2,1),EOMONTH(A2,0))
where the date to check is in A2.
Custom format the cell that holds this formula as yyyy-mm
Example attached.
Edit: This one will work also:
=EOMONTH(A2,QUOTIENT(DAY(A2),28))
BigDaveB That could be:
=IF(DAY(A2)>=28,EOMONTH(A2,1),EOMONTH(A2,0))
where the date to check is in A2.
Custom format the cell that holds this formula as yyyy-mm
Example attached.
Edit: This one will work also:
=EOMONTH(A2,QUOTIENT(DAY(A2),28))
- BigDaveBNov 17, 2021Copper Contributor
Hi Riny,
Thanks so much for that. I wasn't even close to that and was trying to build nested If (OR) statements that were long and complicated. But your formula hit the nail on the head.
I made one small change to allow for sorting and filtering of the column to suit my needs=TEXT(IF(DAY(A2)>=28,EOMONTH(A2,1),EOMONTH(A2,0)),"yyyy-mm")
Again, thank you so much for this.
Dave
- Riny_van_EekelenNov 17, 2021Platinum Contributor
BigDaveB Glad it worked out. By the way, I just added another formula to my original post. It's a little bit more fancy 🙂