Documentation

eomdate

Last date of month

Syntax

DayMonth = eomdate(Date)
DayMonth = eomdate(Year, Month, outputType)

Description

DayMonth = eomdate(Date) returns the serial date number of the last date of the month for the given Date. Enter Date as a four-digit integer, date character vector, or datetime array. If Date is a serial date number or a date character vector, DayMonth is returned as a serial date number. If Date is a datetime array, then DayMonth is returned as a datetime array.

DayMonth = eomdate(Year, Month, outputType) returns the serial date number of the last date of the month for the given year and month. Enter Year as a four-digit integer; enter Month as an integer from 1 through 12. With this syntax, the type of DayMonth is controlled by outputType. If outputType is 'datenum', then DayMonth is a serial date number. However, if outputType is 'datetime', then DayMonth is a datetime array. By default, outputType is 'datenum'.

Either input argument for Year and Month can contain multiple values, but if so, the other input must contain the same number of values or a single value that applies to all. For example, if Year is a 1-by-n vector of integers, then Month must be a 1-by-n vector of integers or a single integer. DayMonth is then a 1-by-n vector of date numbers.

Use the function datestr to convert serial date numbers to formatted date character vectors or datenum to convert date and time to a serial date number.

Examples

DayMonth = eomdate(2001, 2)
DayMonth =
      730910
datestr(DayMonth)
ans =
28-Feb-2001
DayMonth = eomdate(datetime('1-Jan-2015','Locale','en_US'))
DayMonth = 

   31-Jan-2015
Year = [2002 2003 2004 2005];
DayMonth = eomdate(Year, 2)
DayMonth =
      731275      731640      732006      732371
datestr(DayMonth)
ans =
28-Feb-2002
28-Feb-2003
29-Feb-2004
28-Feb-2005
DayMonth = eomdate(2001, 2,'datetime')
DayMonth = 

   28-Feb-2001

Related Examples

See Also

| | | | |

Introduced before R2006a

Was this topic helpful?