MONTH
Returns the month, a number from 1 (January) to 12 (December).
Syntax
expression.MONTH(arg1-);
expression - A variable that represents a ApiWorksheetFunction class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| arg1- | Required | ApiRange | ApiName | number | A number in the date-time code. |
Returns
number
Example
Extract the month component from a date in a spreadsheet.
// What month does a date represent in a spreadsheet?
// Get the month as a number from a date in a spreadsheet.
const worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
let ans = func.MONTH("3/16/2018");
worksheet.GetRange("C1").SetValue(ans);