Click or drag to resize

Year Function

Extract the number of the year from a date.

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

Parameters

dDate
Type: Date
The date.

Return Value

Type: UInt32
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#
? TODAY()                                        // 09/20/90
? YEAR(TODAY())                        // 1990
? YEAR(TODAY()) + 11                // 2001
? YEAR(05.15.64)                        // 1964
SetEpoch(2000)
? 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#
? Mdy(TODAY())                                // September 20, 1990
FUNCTION Mdy(dDate)
        RETURN CMONTH(dDate) + " " + ;
                        NTrim(DAY(dDate)) ;
                        + "," + STR(YEAR(dDate))
See Also