Avatar of Steve_Brady
Steve_Brady
Flag for United States of America asked on

Change the written name of a month into its numerical equivalent in Excel

Hello,

Is there a formula in Excel (2010) that will change the written name of a month into its numerical equivalent?

I frequently run across date entries in which the year and day are specified by numbers but the month is specified by a word. For example, the following is from the Date&Time column in a database of recorded events from a webpage:
...
May 20, 2012 7:55:14 PM          >>>          05/20/12
May 20, 2012 2:26:33 PM          >>>          05/20/12
May 20, 2012 9:33:20 AM          >>>          05/20/12
May 19, 2012 9:47:38 AM          >>>          05/19/12
May 18, 2012 11:57:02 PM          >>>          05/18/12
May 18, 2012 11:52:19 PM          >>>          05/18/12
May 18, 2012 12:42:01 PM          >>>          05/18/12
...

The long entries on the left reveal the format of the original data and the familiar 2-slash dates on the right display the desired format with the time discarded.

The following code effects the conversion:

=DATE(
    MID(A1,SEARCH(",",A1)+2,4),
    IF(LEFT(A1,3)="Jan",1,
        IF(LEFT(A1,3)="Feb",2,
        IF(LEFT(A1,3)="Mar",3,
        IF(LEFT(A1,3)="Apr",4,
        IF(LEFT(A1,3)="May",5,
        IF(LEFT(A1,3)="Jun",6,
        IF(LEFT(A1,3)="Jul",7,
        IF(LEFT(A1,3)="Aug",8,
        IF(LEFT(A1,3)="Sep",9,
        IF(LEFT(A1,3)="Oct",10,
        IF(LEFT(A1,3)="Nov",11,
        IF(LEFT(A1,3)="Dec",12)))))))))))),
    MID(A1,SEARCH(" ",A1)+1,SEARCH(",",A1)-1-SEARCH(" ",A1))
    )

Open in new window

However, it would certainly be a lot simpler and cleaner if there was a single function, etc., for the Month argument.  In fact, for something so common, I anticipate there is (a function) and I have just not yet learned it.  

In if that is not the case however, feel free to copy the following to save in your bag of shortcuts for the next time you need it.

=IF(LEFT(A1,3)="Jan",1,
IF(LEFT(A1,3)="Feb",2,
IF(LEFT(A1,3)="Mar",3,
IF(LEFT(A1,3)="Apr",4,
IF(LEFT(A1,3)="May",5,
IF(LEFT(A1,3)="Jun",6,
IF(LEFT(A1,3)="Jul",7,
IF(LEFT(A1,3)="Aug",8,
IF(LEFT(A1,3)="Sep",9,
IF(LEFT(A1,3)="Oct",10,
IF(LEFT(A1,3)="Nov",11,
IF(LEFT(A1,3)="Dec",12))))))))))))

Open in new window

Thanks
Microsoft Excel

Avatar of undefined
Last Comment
Steve_Brady

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
dlmille

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
nito8300

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
nito8300

Then you can just format the cells, select Custom and use mm/dd/yy
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
dlmille

barry, will =Month(1&A1) work with 3 character month names, as well?

Dave
byundt

Dave,
Did it not do so in your tests?

It did in mine.

Brad
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
dlmille

Thanks for that, Brad, lol.

Neat stuff.  Amazing the backflips you guys come up with.  (by backflips, I mean the stuff that's not obvious).

Cheers,

Dave
Steve_Brady

ASKER
Great responses.  Thanks