Excel 2000 and date math

R

rasinc

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
 
P

Pete_UK

Try this:

=DATE(YEAR(A1)-1,MONTH(A1),DAY(A1))

Note that if you put 2/28/2008 in A1, you will get 3/1/2007 as the
result (i.e. 1st March, as 29th Feb 2007 doesn't exist) - is this what
you want?

Hope this helps.

Pete
 
M

macropod

Hi rasinc,

For a date in A1:
=MIN(DATE(YEAR(A1),MONTH(A1)-1+{0,1},DAY(A1)*{1,0}))
You can use the above for any number of months before & after the nominated date, simply by changing the '-1' to whatever you need.
 

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

Similar Threads


Top