DAYNAME scalar function

The DAYNAME function returns a character string containing the name of the day (for example, Friday) for the day portion of the input value.

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

The schema is SYSIBM. The SYSFUN version of the DAYNAME 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.

expression
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.
locale-name
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

Notes

  • 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 DAYNAME function assumes the Gregorian calendar for all calculations.
  • Determinism: DAYNAME 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).

Example

Assume that the variable TMSTAMP is defined as TIMESTAMP and has the following value: 2007-03-09-14.07.38.123456. 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
--------------------------                      ----------
DAYNAME (TMSTAMP, 'CLDR181_en_US')              Friday
DAYNAME (TSMTAMP, 'CLDR181_de_DE')              Freitag
DAYNAME (TMSTAMP, 'CLDR181_fr_FR')              vendredi