Saturday, January 8, 2011

Convert month in text to number

When we pull data from different sources i.e. SQL, txt file, CSV files...., The date columns are imported in text format because of their source data type or could be due to any other reason.

For example - You have data of month in text format with no fixed length(at least three characters) like Jan, Febr, March, Apr, May etc. & you want to convert them into number as 1,2,3,4,5.

In this case, the best formula you can use to convert month in text to number is =Month(A1&1) or =Month("Apr"&1)

I am not sure you are going to use this function directly but you can use it as sub function in Date function as well like
=DATE(2011, MONTH(A1&1),2)

***This formula is submitted by Manoj Kumar in the Group Puzzle. Thanks Manoj.***

If you have any feedback or better solution , Feel free the write the comment.