MONTHNAME scalar function

The MONTHNAME function returns a character string containing the name of the month (for example, January) for the month portion of the input value.

Read syntax diagramSkip visual syntax diagramMONTHNAME(expression ,locale-name )

The schema is SYSIBM. The SYSFUN version of the MONTHNAME function continues to be available.

The character string returned is based on locale-name or the value of the special register CURRENT LOCALE LC_TIME.

An expression that returns a value of one of the following built-in data types: a DATE, TIMESTAMP, or a valid character string representation of a date or timestamp that is not a CLOB. In a Unicode database, if a supplied argument is a graphic string, it is first converted to a character string before the function is executed.
A character constant that specifies the locale used to determine the language of the result. The value of locale-name is not case-sensitive and must be a valid locale (SQLSTATE 42815). For information about valid locales and their naming, see Locale names for SQL and XQuery. If locale-name is not specified, the value of the special register CURRENT LOCALE LC_TIME is used.

The result is a varying-length character string. The length attribute is 100. If the resulting string exceeds the length attribute of the result, the result will be truncated. If the expression argument can be null, the result can be null; if the expression argument is null, the result is the null value. The code page of the result is the code page of the section. The string units of the result is determined by the string units of the environment.


  • Julian and Gregorian calendar: The transition from the Julian calendar to the Gregorian calendar on 15 October 1582 is taken into account by this function. However, the SYSFUN version of the MONTHNAME function assumes the Gregorian calendar for all calculations.
  • Determinism: MONTHNAME is a deterministic function. However, when locale-name is not explicitly specified, the invocation of the function depends on the value of the special register CURRENT LOCALE LC_TIME. This invocation that depends on the value of a special register cannot be used wherever special registers cannot be used (SQLSTATE 42621, 428EC, or 429BX).


Assume that the variable TMSTAMP is defined as TIMESTAMP and has the following value: 2007-03-09- The following examples show several invocations of the function and the resulting string values. The result type in each case is VARCHAR(100).

Function invocation                              Result
--------------------------                      ----------
MONTHNAME (TMSTAMP, 'CLDR181_en_US')              March
MONTHNAME (TSMTAMP, 'CLDR181_de_DE')              Marz
MONTHNAME (TMSTAMP, 'CLDR181_fr_FR')              mars