GOMONTH( ) function

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

Syntax

GOMONTH(date/datetime, months)

Parameters

date/datetime

Datetime. The field, expression, or literal value from which to calculate the output date.

months

Numeric constant. Specifies the number of months before or after the date in the date/datetime parameter.

Output

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

Remarks

If the value in the months parameter is positive, the output date is more recent than the specified date/datetime. If the value is negative, the output date is prior to the specified date/datetime. If the parameter is omitted, or a value of ‘0’ (zero) is used, the output date is the same as the date/datetime.

The date/datetime parameter can accept a datetime value, but the time portion of the value is ignored.

A field specified for the date/datetime parameter 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 or YYMMDD. You must enclose literal date values in backquotes (for example, `20141231`).

If the combination of the date/datetime and months parameters would produce a non-existent date, the GOMONTH( ) function uses ‘date rounding’ to return the closest valid date within the same month. For example, GOMONTH(`20140331`,1) returns 30 Apr 2014 because 31 Apr 2014 is an invalid date.

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

Examples

Example Return value

GOMONTH(`20140115`, 3)

15 Apr 2014

Assumes a current ACL date display format of DD MMM YYYY

GOMONTH(`20140115`, -3)

15 Oct 2013

Assumes a current ACL date display format of DD MMM YYYY

GOMONTH(Invoice_date, 3)

The date three months after each date in the Invoice_date field.

GOMONTH(Invoice_date+15, 3)

The date three months after each date in the Invoice_date field plus a grace period of 15 days.

GOMONTH(`20140330`,1)

GOMONTH(`20140331`,1)

GOMONTH(`20140401`,1)

30 Apr 2014

30 Apr 2014

01 May 2014

Date rounding prevents GOMONTH(`20140331`,1) from returning 31 Apr 2014, which is an invalid date.

Related reference
EOMONTH( ) function


(C) 2015 ACL Services Ltd. All Rights Reserved.