Year

Description

Gets the year of a date value.

Syntax

Year ( date )

Argument

Description

date

The date value from which you want the year

Returns

Integer. Returns an integer whose value is a 4-digit year adapted from the year portion of date if it succeeds and 1900 if an error occurs.

If the year is two digits, then the century is set as follows. If the year is between 00 to 49, the first two digits are 20; if the year is between 50 and 99, the first two digits are 19.

Usage

Obtains the year portion of date. Years from 1000 to 3000 inclusive are handled.

If your data includes dates before 1950, such as birth dates, always specify a 4-digit year so that Year (and other functions, such as Sort) interpret the date as intended.

NoteRegional settings To make sure you get correct return values for the year, you must verify that yyyy is the Short Date Style for year in the Regional Settings of the user’s Control Panel. Your program can check this with the RegistryGet function.

If the setting is not correct, you can ask the user to change it manually or to have the application change it (by calling the RegistrySet function). The user might need to reboot after the setting is changed.

Examples

Example 1

This expression returns 2005:

Year(2005-01-31)

See also