Official Content

Adds a given number of months to a given date.

Syntax

Date | DateTime.AddMonths(Numeric-expression)

Where:

Date | DateTime
     Is an attribute or variable based on the Date/DateTime data type, to which the method will add a certain number of months.

Numeric-expression
     Is the number of months added to the given Date | DateTime.

Type returned:
Date | DateTime

Scope

Data Types:   Date DateTime

Description

Returns a value that results from adding a number of months to a given date or date with time.

The result data type will be the same as the given original value (Date or DateTime).

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

Samples

&ExpirationDate = &Today.AddMonths(1)    //This line can be included, for example, in a Procedure Source or in an Event
Event 'Calculates Expiration DateTime'
   &Now=Now()                            //&Now is a variable based on the DateTime data type
   &ExpirationDateTime = &Now.AddMonths(1)          
Endevent

See Also

AddMth function
AddYears method
AddDays method

  


  
Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant