troubleshooting Question

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

Avatar of Steve_Brady
Steve_BradyFlag for United States of America asked on
Microsoft Excel
9 Comments4 Solutions329 ViewsLast Modified:
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))
    )
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))))))))))))
Thanks
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 4 Answers and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 4 Answers and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros