View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.misc
Rick Rothstein \(MVP - VB\) Rick Rothstein \(MVP - VB\) is offline
external usenet poster
 
Posts: 2,202
Default Trouble adding or subtracting from the current month

That won't give the correct result in all circumstances, e.g. on 30th and
31st May it'll return "March".

7th January 1900.

If you want to feed TEXT with a date 3 months ago, try
=TEXT(DATE(YEAR(TODAY()),MONTH(TODAY())-3,DAY(TODAY())),"mmmm")
[but remember the usual questions, such as what date do you regard as
being
3 months before 31st May?]


I'm not sure why my formula works when David's doesn't (for the dates you
mentioned), but I figured the actual date is immaterial for getting the
month, so I prefilled the year and day in and got this...

=TEXT(DATE(2000,MONTH(A1)-3,1),"mmmm")

which returns February for the dates you mentioned (the date being in A1
for my example formula). So now the question is.... why does it work when
David's doesn't?


Never mind... I know why mine works... I use the first of the month for the
calculation thus avoiding end-of-month issues for months with differing
number of days. Again, since the month is all we are after, the year and day
are immaterial, so using any year and day one should always work (and the
formula is rather tight to boot).