AddMth function

Official Content
This documentation is valid for:

To add a specific number of months to a given date.

Syntax

AddMth(date-expression | datetime-expression , numeric-expression)

Type Returned:
   Date | Datetime

Where:
date-expression | datetime-expression
   Given date or datetime.

numeric-expression
   The number of months added to the date-expression | datetime-expression.

Description

Returns a value that results from adding numeric-expression months to date-expression or datetime-expression. When the type assigned is date, it returns a date value, and when the type assigned is datetime it returns a datetime.

If the numeric expression is negative, the months are subtracted from the given date.

Examples

Date1 = ADDMTH(Today(),2) // Today() = 31/03/2008
// Result: Date1 = 31/05/2008 if Date1 is a date type attribute

Date2 = ADDMTH(Today(),1) // Today() = 31/03/2008
// Result: Date2 = 30/04/2008 00:00:00 if Date2 is a datetime type attribute

Date3 = ADDMTH(Date2,1) // Date2 = 30/04/2008
// Result: Date3 = 30/05/2008 if Date3 is a date type attribute

Date4 = ADDMTH(Today(),-2) // Today() = 21/09/2008
// Result: Date4 = 21/07/2008 if Date2 is a date type attribute

Date5 = ADDMTH(Now(),1) // Now() = 21/08/2008 16:30:12
// Result: Date5 = 21/09/2008 if Date5 is a date type attribute 
// Result: Date5 = 21/09/2008 16:30:12 if Date5 is a datetime type attribute 

Note that the resulting value corresponding to Date1 is different from the result in Date 3, so different results may be obtained when adding two months to a date (Date1 case), or adding one month twice (Date2, Date3 case). You can also subtract months from a given date (e.g. Date4).

Scope

Objects   Procedure object, Transaction object, Web Panel object

See also

AddMonths method
AddYr function
Add days syntax