EOMONTH( ) function

Returns the date of the last day of the month that is the specified number of months before or after a specified date.

Syntax

EOMONTH(<date/datetime> <,months>)

Parameters

Name Type Description
date/datetime

optional

datetime

The field, expression, or literal value from which to calculate the end-of-month date. If omitted, the end-of-month date is calculated from the current operating system date.

Note

You can specify a datetime value for date/datetime but the time portion of the value is ignored.

months

optional

numeric

The number of months before or after date/datetime. If omitted, the default of 0 (zero) is used.

You cannot specify months if you have omitted date/datetime.

Output

Datetime. The date value is output using the current Analytics date display format.

Examples

Basic examples

No input

Returns the last day of the month for the current operating system date:

EOMONTH()

Literal input values

Returns `20140131` displayed as 31 Jan 2014 assuming a current Analytics date display format of DD MMM YYYY:

EOMONTH(`20140115`)

Returns `20140430` displayed as 30 Apr 2014 assuming a current Analytics date display format of DD MMM YYYY:

EOMONTH(`20140115`, 3)

Returns `20131031` displayed as 31 Oct 2013 assuming a current Analytics date display format of DD MMM YYYY:

EOMONTH(`20140115`, -3)

Field input values

Returns the last day of the month that falls three months after each date in the Invoice_date field:

EOMONTH(Invoice_date, 3)

Returns the last day of the month that falls three months after each date in the Invoice_date field plus a grace period of 15 days:

EOMONTH(Invoice_date + 15, 3)

Returns the first day of the month in which the invoice date falls:

EOMONTH(Invoice_date, -1) + 1

Remarks

Datetime formats

A field specified for date/datetime can use any date or datetime format, as long as the field definition correctly defines the format.

A literal date value must use one of the following formats:

  • YYYYMMDD
  • YYMMDD

You must enclose literal date values in backquotes. For example: `20141231`

How the months value works

  • Positive value the output date is more recent than the specified date/datetime
  • Negative value the output date is prior to the specified date/datetime
  • Value omitted, or '0' (zero) the output date is the last day of the month in which the date/datetime occurs

Return the date of the first day of a month

Add 1 day to the result of the EOMONTH( ) function to return the date of the first day of a month.

Returns `20140201` displayed as 01 Feb 2014 assuming a current Analytics date display format of DD MMM YYYY:

EOMONTH(`20140115`) + 1

Related functions

Use the GOMONTH( ) function if you want to return the exact date, rather than the date of the last day of the month, that is the specified number of months before or after a specified date.

ACL Scripting Guide 14.1