Take the 2-minute tour ×

Is there a best way to turn an integer into its month name in .net?

Obviously I can spin up a datetime to string it and parse the month name out of there. That just seems like a gigantic waste of time.

share|improve this question
add comment

6 Answers

up vote 163 down vote accepted

Try GetMonthName from DateTimeFormatInfo


You can do it by:

share|improve this answer
add comment
share|improve this answer
Thats a good one too :) –  leppie Oct 20 '08 at 16:01
This doesn't work. Nick Berardi provided the correct answer. –  raven Oct 20 '08 at 16:58
This is where the functionality is, if you want me to write code for you ... –  Ovidiu Pacurar Oct 20 '08 at 18:18
from now I will try to compile my answers first –  Ovidiu Pacurar Oct 20 '08 at 18:19
130 points for an answer that doesn't compile... nice. :) –  Jeremy Wiggins Mar 12 '12 at 21:43
show 1 more comment

Why not just use somedatetime.ToString("MMMM")?

share|improve this answer
So anytime I need to turn 1 into January, I need to new up a date time with an arbitrary year and day, in order to just get January? –  DevelopingChris Oct 20 '08 at 15:56
That is correct, as a bonus, you can have it in any localizable language you want :) –  leppie Oct 20 '08 at 15:57
add comment

You can use a static method from the Microsoft.VisualBasic namespace:

string monthName = Microsoft.VisualBasic.DateAndTime.MonthName(monthInt, false);
share|improve this answer
add comment
Response.Write(day + "-" + dt.ToString("MMMM") + "-" + year);

In this way, your month will be displayed by their name, not by integer.

share|improve this answer
add comment

To get abbreviated month value, you can use Enum.Parse();

Enum.Parse(typeof(Month), "0");

This will produce "Jan" as result.

Remember this is zero-based index.

share|improve this answer
add comment

Your Answer


