doubledate.eom#

doubledate.eom(date: date, offset: int = 0)#

Returns the last date of month for the given date, then optionally offsets it by offset months.

Parameters:
  • date (datetime.date) – The date for which to compute the end of the month

  • offset (int, optional) – The number of months from which to offset the end of the month

Returns:

The end of the month

Return type:

datetime.date

Note

This function emulates Excel’s EOM function

Examples

>>> today = datetime.date(2020, 1, 15)
>>> eom(today)
datetime.date(2020, 1, 31)
>>> eom(today, 1)
datetime.date(2020, 2, 29) #2020 is a leap year
>>> eom(today, -1)
datetime.date(2019, 12, 31) #end of previous month

See also

som

compute the start of the month