Click or drag to resize

Year Function

X#
Extract the number of the year from a date.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax
 FUNCTION Year(
	dDate AS DATE
) AS DWORD
Request Example View Source

Parameters

dDate
Type: Date
The date.

Return Value

Type: DWord
The year of dDate, including the century digits, as a 4-digit number.
The value returned is not affected by SetDateFormat(), SetCentury(), SET DATE, or SET CENTURY. Specifying a NULL_DATE returns 0.
Remarks
Year() is a date conversion function that converts a date value to a numeric year value.
If the century digits are not specified, the century is determined by the rules of SET EPOCH or SetEpoch(). Year() is a member of a group of functions that return components of a date value as numbers.
The group includes Day() and Month(), which return the day and month values as numbers.
Examples
These examples illustrate Year() using the system date:
X#
1? TODAY()                    // 09/20/90
2? YEAR(TODAY())            // 1990
3? YEAR(TODAY()) + 11        // 2001
4? YEAR(05.15.64)            // 1964
5SetEpoch(2000)
6? YEAR(CTOD("05.15.64"))    // 2064
This example creates a function using Year() to format a date value in the form month, day, year:
X#
1? Mdy(TODAY())                // September 20, 1990
2FUNCTION Mdy(dDate)
3    RETURN CMONTH(dDate) + " " + ;
4            NTrim(DAY(dDate)) ;
5            + "," + STR(YEAR(dDate))
See Also