ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   date calculation (https://www.excelbanter.com/excel-worksheet-functions/169450-date-calculation.html)

user@msn

date calculation
 
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

bpeltzer

date calculation
 
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)

"user@msn" wrote:

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


Ron Rosenfeld

date calculation
 
On Wed, 12 Dec 2007 10:41:04 -0800, user@msn
wrote:

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


All times are GMT +1. The time now is 10:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com