View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
David Biddulph[_2_] David Biddulph[_2_] is offline
external usenet poster
 
Posts: 8,651
Default Excel 2000 and date math

=DATE(Year(A1),Month(A1)-1,Day(A1)) will give 3/3/09 in the case of your
first example. You may need to derive your own function if that's not what
you want.
Perhaps =MIN(DATE(YEAR(A1),MONTH(A1)-1,DAY(A1)),DATE(YEAR(A1),MONTH(A1),0))
?

=DATE(Year(A1)-1,Month(A1),Day(A1)) will give a year earlier, but to cope
with an input such as 29 Feb 2008 you may want
=MIN(DATE(YEAR(A1)-1,MONTH(A1),DAY(A1)),DATE(YEAR(A1)-1,MONTH(A1)+1,0)).
--
David Biddulph

rasinc wrote:
I am trying to allow a user to enter a date and then calculate the
month before.

Eg. Enter in Cell A1 3/31/2009
Cell A2 will calculate automatically 2/28/2009

If Cell A1 is 1/1/2009 then A2 should automatically calculate
12/1/2008 so that years and leap years are accounted for.

Ultimately I want to be able to calculate the same month in the
previous year but I think I can do this with
Month(A1)&"/"&Day(A1)&"/"&Year(A1)-1.

I was trying to find a DateAdd function but can't so I am not sure
how to approach this directly in Excel or should I get into VBA
(never really done this before).

Any help is appreciated TIA rasinc