Not sure how you're getting 27th by adding 2 weeks to 1st

Weeks =D3-WEEKDAY(D3+1)+(D5*7)
Months =EOMONTH(D3,0)