Function Year() Foundation

Extracts the year from a date value as a numeric value.

Syntax
Year( <dDate> ) --> nYear
Parameters
<dDate>
<dDate> is a date value whose year number is determined.
Return

The return value of Year() is an integer with four digits which designate the year of the date value, including the century. Zero is returned for an empty date (CtoD("")).

Description

The conversion function Year() extracts the year from a date value and returns it as a numeric value. Similar functions are Day() and Month() which also produce a numeric value from a date value. Year() is generally used for the formatted output of a date.

Examples
Year()
// The example shows the return value of Year() and includes 
// a user-defined function which transforms a date value to an 
// alphanumeric character string. 

PROCEDURE Main 

    ? Date()                         // result: 12/06/94 
    ? Year( Date() )                 // result: 1994 
    ? DateString( Date() )           // result: December 6, 1994 

RETURN 

FUNCTION DateString( dDate ) 
RETURN  CMonth  ( dDate )             + " "  + ; 
        LTrim(Str( Day( dDate ), 2) ) + ", " + ; 
        Str(Year( dDate ), 4 ) 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.