Will the formula below change to November automatically next month?

VBAProIWish

Well-known Member
Joined
Jul 6, 2009
Messages
1,027
Office Version
  1. 365
Platform
  1. Windows
Hello all,

The formula below automatically enters in "Oct" as of today, 10-14-14. Will anyone please tell me if this cell automatically changes to "Nov" on 11-01-14?...

Code:
=TEXT(DATE(2004,IF(MONTH(TODAY())>0,MONTH(TODAY()),12),1),"MMM")

Thanks much
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Thanks to both. I was told that I have to use that formula because I'm using the same slightly edited formula to say the previous month like this...

Code:
=TEXT(DATE(2004,IF(MONTH(TODAY())>0,MONTH(TODAY()),12),1),"MMM")

and they said that using a simpler formula like
Code:
[COLOR=#333333]=TEXT(TODAY(),"mmm")[/COLOR]
wouldn't work properly because when January rolls around, it won't show December.

Any thoughts? Is this true?

Thanks
 
Upvote 0
The logical test for the IF formula is not logical at all, it will be TRUE for all cases:

MONTH(TODAY())>0

Hence its uneccessary and Jonmo1's formula should suffice.

This will give you the name of previous month:

=TEXT(EOMONTH(B1,-1),"mmm")
 
Last edited:
Upvote 0
Let's break down the formula...

=TEXT(DATE(2004,IF(MONTH(TODAY())>0,MONTH(TODAY()),12),1),"MMM")

MONTH(TODAY()) can only return a number from 1 to 12, it CANNOT return 0 or 13+

Therefor MONTH(TODAY()) will ALWAYS be a number greater than 0.
So
MONTH(TODAY())>0 will ALWAYS be true, it will NEVER Be false.

So, the date function will ALWAYS use
MONTH(TODAY()) as the month argument.
It will never use 12 (except when it is currently actually within the month of December)
But in that case, it's still because of Month(Today())>0 being True.
Not because of the 12 hard coded into the False part of the IF.

So the formula will ALWAYS return the Current Month in text format.
As will
=TEXT(TODAY(),"mmm")

The Year is completely irrelevant, because you're using 1 as the DAY argument in the Date function.
And The formula is only interested in the MONTH, not the actual complete date.
The only way the year would ever matter is in a Non Leap year, and you were using 29+ as the DAY argument.


There is no cercumstance in which these 2 formulas would produce different results.
=TEXT(DATE(2004,IF(MONTH(TODAY())>0,MONTH(TODAY()),12),1),"MMM")
=TEXT(TODAY(),"mmm")


By the way, who is 'They' ?
 
Last edited:
Upvote 0
I was told that I have to use that formula because I'm using the same slightly edited formula to say the previous month like this...
The formula you posted will not return the 'previous' month.

If the goal is to return the previous month, try

=TEXT(DATE(2004,MONTH(TODAY()),0),"MMM")
 
Upvote 0
omg, I have spent the last 20 minutes trying to find that conversation about the previous date issue and why it had to be like that. I totally believe you Jonmo, but I really want you to see that discussion on here. I searched all my posts and cannot find the thread :(. Feel free to search on "TEXT(DATE(2004,IF("

There will be many posts containing that text, I just don't know where I found it. Thank you for the great explanation though!

P.S. If you decide to search for the thread and find it, please let me know.

Thanks much! :)
 
Upvote 0
To be clear, I'm not trying to say your formula is 'wrong'.
It certainly does give the desired result of the current month in text format.

I'm just saying that it's just unnecessarily over complicated.
Just trying to help by showing that the same result can be achieved with a much simpler formula.

Also, I'm pretty sure your actual question was answered with the very first reply by madaknarf
Yes, the formula will change to Nov come November first.

So I think I'll pass on the research... ;)
 
Upvote 0
lol, allllll good. I actually got that code from somewhere on this forum and don't want to take credit for it.

Maybe the original person that gave me the code, gave it to me because I wanted it in code format, but I'm sure your code works that way also.

Thanks so much for your input! :)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,541
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top