Skip to main content

EOMONTH

Returns the serial number of the last day of the month before or after the specified number of months.

Syntax

expression.EOMONTH(arg1, arg2);

expression - A variable that represents a ApiWorksheetFunction class.

Parameters

NameRequired/OptionalData typeDefaultDescription
arg1RequiredApiRange | ApiName | numberA serial date number that represents the start date.
arg2RequiredApiRange | ApiName | numberThe number of months before or after the start date.

Returns

number

Example

Return the serial number of the last day of the month before or after the specified number of months in a spreadsheet.

// How to get a date of the last day of the month before or after specified months in a spreadsheet.

// Use function to get the serial number of the last day of the month before or after the specified number of months in a spreadsheet.

const worksheet = Api.GetActiveSheet();

let func = Api.WorksheetFunction;
let ans = func.EOMONTH("3/16/2018", 10);

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