MonthName() in Classic ASP

MonthName() converts a month number from 1 to 12 into its full or abbreviated name. It uses the current ASP locale, so names can differ by language and regional settings.

<%
Response.Write MonthName(10)
%>

Output in an English locale: October.

On this page — Show page sectionsHide page sections

Syntax and parameters

MonthName(month[, abbreviate])
ParameterDescription
monthMonth number, from 1 (January) to 12 (December)
abbreviateOptional Boolean: True for short name; False for full name (default)

Full month name

MonthName(10)

Returns October under English locale settings.

Explicit full month name

MonthName(10, False)

The optional False argument requests the full form.

Abbreviated month name

MonthName(10, True)

Returns Oct under English locale settings.

MonthName() from a Date value

<%
Dim myDate
myDate = DateSerial(2026, 11, 13)
Response.Write MonthName(Month(myDate))
%>
November

This combines Month(), which extracts the numeric month, with MonthName(), which produces the display label.

Print all twelve months

<%
Dim monthNo
For monthNo = 1 To 12
  Response.Write monthNo & ": " & MonthName(monthNo) & "<br>"
Next
%>

This produces January through December under an English locale. It is useful for reports or form dropdown labels.

Full and abbreviated names together

<%
Dim monthNo
For monthNo = 1 To 12
  Response.Write MonthName(monthNo, False) & " (" & _
    MonthName(monthNo, True) & ")<br>"
Next
%>
<label for="month">Month</label>
<select name="month" id="month">
<% Dim monthNo
For monthNo = 1 To 12 %>
  <option value="<%=monthNo%>"><%=MonthName(monthNo)%></option>
<% Next %>
</select>

Send the numeric value to your server, not the localized label. Always validate submitted values before constructing dates with DateSerial().

Locale-aware names

<%
Dim previousLocale
previousLocale = SetLocale(1033) ' English (United States)
Response.Write MonthName(3, False)
SetLocale previousLocale
%>

The English result is March. Month names are intended for display; do not use them as stable language-independent identifiers.

Common mistakes

A month value outside 1 through 12 is invalid. Validate it before calling MonthName(). To obtain the number from a date use Month(myDate), not MonthName(myDate).

Frequently asked questions

How do I get just "Nov" instead of "November"?

Pass True: MonthName(11, True).

Can I get the current month name?

Yes: MonthName(Month(Date)).

Are MonthName() values always English?

No. They depend on the ASP locale.

How do I display the full date?

Use FormatDateTime() with an appropriate named format.

Back to top ↑


ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer