eomdate

Date number of the last day of a month.

Category: Language Fundamentals > Data Types

Syntax

n = eomdate(y, m)

Last day of month m in year y, as a date number.

n = eomdate(d)

Last day of the month containing the date d.

Description

The result is a date number, so display it with datestr, as in datestr(eomdate(2024,2)). It accounts for leap years. To get the day of the month as a plain number, eomday is simpler.

Input arguments

y, m
Year and month (scalars).
d
Date number or datetime.

Output arguments

n
Date number (datenum) at midnight of the last day of the month.

Example

End of February

n = eomdate(2024, 2)
datestr(n)
Output
n = 739311
ans = '29-Feb-2024'

Notes

Only scalar inputs are handled correctly: with a vector of years or months MatLivre returns only the first result. In MATLAB eomdate takes year and month arrays.

See also

eomday datenum datestr calendar dateshift