跳到主要内容

YEAR

Returns the year of a date, an integer in the range 1900-9999.

Syntax

expression.YEAR(arg1);

expression - A variable that represents a ApiWorksheetFunction class.

Parameters

NameRequired/OptionalData typeDefaultDescription
arg1RequiredApiRange | ApiName | numberA number in the date-time code, or a result of other formulas or functions.

Returns

number

Example

const worksheet = Api.GetActiveSheet();

let func = Api.GetWorksheetFunction();
let ans = func.YEAR("3/16/2018");

worksheet.GetRange("C1").SetValue(ans);