date calculation

U

user@msn

I need a formula that will return the last day of the month for a period of
two months prior to the date I enter. For example, if I enter 1/1/08 in Cell
A1, I want Cell B1 to return 11/30/07; if I enter 2/1/08 in Cell A1, I want
Cell B1 to return 12/31/07, etc..

P.S. Cell A1 will always be the first day of the month (if that matters)

Thanks
 
B

bpeltzer

Since the 0th day of one month is the last day of the prior month,
=DATE(YEAR(A1),MONTH(A1)-1,0) (the 0th day of last month).
Or, if A1 is always the 1st of the month, you could also use
=A1-DAY(A1-1)-1 (subtract from A1 the number of days in the prior month,
plus 1)
 
R

Ron Rosenfeld

I need a formula that will return the last day of the month for a period of
two months prior to the date I enter. For example, if I enter 1/1/08 in Cell
A1, I want Cell B1 to return 11/30/07; if I enter 2/1/08 in Cell A1, I want
Cell B1 to return 12/31/07, etc..

P.S. Cell A1 will always be the first day of the month (if that matters)

Thanks


=A1-DAY(A1)-DAY(A1-DAY(A1))

and it doesn't matter what day of the month is in A1.
--ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top