ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Date in an IF statement (https://www.excelbanter.com/excel-worksheet-functions/16653-date-if-statement.html)

LyndieBee

Date in an IF statement
 
I'd like to be able to evaluate the current date and have the name of the
previous month display in a cell. For example if I'm in cell A1 I want the
statement to check today's date (March 8, 2005) and return last month's month
"April". Can I accomplish this with an IF statement? Any other function?
Many thanks, Lyndie

JulieD

Hi

i would have thought that last month's month was Feburary and next month's
month was April ... however, here's two options
- returns Feburary
=TEXT(EOMONTH(NOW(),-1),"mmmm")
- returns April
=TEXT(EOMONTH(NOW(),1),"mmmm")

Note, to use the EOMONTH function you need to have the Analysis Tool-Pak
add-in installed (tools / add-ins)

Cheers
JulieD

"LyndieBee" wrote in message
...
I'd like to be able to evaluate the current date and have the name of the
previous month display in a cell. For example if I'm in cell A1 I want
the
statement to check today's date (March 8, 2005) and return last month's
month
"April". Can I accomplish this with an IF statement? Any other function?
Many thanks, Lyndie




Ron Rosenfeld

On Tue, 8 Mar 2005 06:59:04 -0800, LyndieBee
wrote:

I'd like to be able to evaluate the current date and have the name of the
previous month display in a cell. For example if I'm in cell A1 I want the
statement to check today's date (March 8, 2005) and return last month's month
"April". Can I accomplish this with an IF statement? Any other function?
Many thanks, Lyndie


To return the previous month,

=TEXT(A1-DAY(A1),"mmmm")

To return the name of the next month:

=TEXT(A1-DAY(A1)+33-DAY(A1-DAY(A1)+32),"mmmm")

Simpler might be to just compute a date in the month, and format the cell as
"mmmm"

Then the above formulas become:

Previous month:

A1-DAY(A1)

Next month:

A1-DAY(A1)+33-DAY(A1-DAY(A1)+32)


--ron


All times are GMT +1. The time now is 08:51 AM.

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