Year – PB Docs 2017

Year

PowerScript function

Description

Determines the year of a date value.

Syntax

Argument

Description

date

The date from which you want the year

Return value

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
date is null, Year returns null.

When you convert a string that has a two-digit year to a date, then
PowerBuilder chooses the century, as follows. If the year is between 00 to
49, PowerBuilder assumes 20 as the first two digits; if it is between 50
and 99, PowerBuilder assumes 19.

Usage

PowerBuilder handles years from 1000 to 3000 inclusive.

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

Windows 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 have the application change it (by calling the
RegistrySet function). The user may need to reboot after the setting is
changed.

Examples

This statement returns 2005:

See also

Day

Month

Year method for DataWindows in the section called “Year” in DataWindow Reference.


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x