B
brettopp
I'm looking for a formula that displays the billing-month start date based on
a user-entered end date. The system I will be using this calculation for
considers billing month periods as ending one month less one day after the
billing month start date. For example, if my billing month starts on April
1, it ends on April 30. If starts on May 1, it ends May 31. If starts on
April 15, it ends on May 14. If starts on February 28, it ends on March 27
(non-leap year). If starts on February 29 (leap year), it ends on March 28.
For example, if a user enters an end date of 31-JAN-08, the billing month
start date that the formula will calculate should show 01-JAN-08. If the
user enters an end date of 15-JAN-08, the billing month start date the
formula will calculate should show 16-DEC-07.
I thought a very easy way to do this would be using the DATE function:
=DATE(YEAR(H5),MONTH(H5)-1,DAY(H5)), where H5 is the cell the user enters the
end date into.
Below are the results I achieved using this formula, which are all over the
place. I have included here only months that have 31 days in them to show
how this formula yields different results even on months with the same number
of days. The first column lists the user-entered end date I entered into
Excel, and the second columns shows the results given by the DATE formula I
listed above.
User-entered end date Billing-month start date
Jan-31-2008 Dec-31-2007
Mar-31-2008 Mar-02-2008
May-31-2008 May-01-2008
Jul-31-2008 Jul-01-2008
Aug-31-2008 Jul-31-2008
Oct-31-2008 Oct-01-2008
Dec-31-2008 Dec-01-2008
Only the months of May, July, October, and December yielded the correct
billing-month start date (which starts on the first of the month in this
example).
The results using this formula were equally chaotic for months with only 30
days in them.
Once last thing to note: In my sample dates above I used the last day of
the month as the user entered end date in order to give a consistent example.
In practice, the user-entered end date can be any day of the month, not just
the last day of the month.
a user-entered end date. The system I will be using this calculation for
considers billing month periods as ending one month less one day after the
billing month start date. For example, if my billing month starts on April
1, it ends on April 30. If starts on May 1, it ends May 31. If starts on
April 15, it ends on May 14. If starts on February 28, it ends on March 27
(non-leap year). If starts on February 29 (leap year), it ends on March 28.
For example, if a user enters an end date of 31-JAN-08, the billing month
start date that the formula will calculate should show 01-JAN-08. If the
user enters an end date of 15-JAN-08, the billing month start date the
formula will calculate should show 16-DEC-07.
I thought a very easy way to do this would be using the DATE function:
=DATE(YEAR(H5),MONTH(H5)-1,DAY(H5)), where H5 is the cell the user enters the
end date into.
Below are the results I achieved using this formula, which are all over the
place. I have included here only months that have 31 days in them to show
how this formula yields different results even on months with the same number
of days. The first column lists the user-entered end date I entered into
Excel, and the second columns shows the results given by the DATE formula I
listed above.
User-entered end date Billing-month start date
Jan-31-2008 Dec-31-2007
Mar-31-2008 Mar-02-2008
May-31-2008 May-01-2008
Jul-31-2008 Jul-01-2008
Aug-31-2008 Jul-31-2008
Oct-31-2008 Oct-01-2008
Dec-31-2008 Dec-01-2008
Only the months of May, July, October, and December yielded the correct
billing-month start date (which starts on the first of the month in this
example).
The results using this formula were equally chaotic for months with only 30
days in them.
Once last thing to note: In my sample dates above I used the last day of
the month as the user entered end date in order to give a consistent example.
In practice, the user-entered end date can be any day of the month, not just
the last day of the month.