Official Content

Returns the numeric month identifier in a given date.

Syntax

Month(Date-Expression | Datetime-Expression)

Type Returned:
Numeric(2)

A null value (0) is returned if the received parameter is null.

Scope

Objects: Procedure, Transaction, Web Panel, Panel, Data Provider
Generators: .NET, .NET Framework, Java, Apple, Android, Angular

Samples

1) 

&Month = Month(CToD('01/01/08')) // Result &Month: 1
&Month = Month(Now()) // Result &Month: 2 If Now() = 25/02/08 10:30 

2)

Suppose you need to define a list of all the Customers whose birthdays are in the current month (in this example, the current month is October).

Consider the following Transaction object:

Customer
{
   CustomerId*
   CustomerName
   CustomerDateOfBirth
   CustomerEmail
}

Create a Procedure object and define the following in its Layout:

CustomerDoBThisMonthLayout

Next, in the Source section of the Procedure object, include the following code:

Print printBlock1
For each Customer
    Where Month(CustomerDateofBirth) = Month(&Today)
        Print printBlock2
EndFor 

The Today variable (&Today), shown above, is a pre-defined GeneXus variable that stores the current date.

The following image shows the list at runtime:

CustomerDoBThisMonthList

See Also

TimeZone Support - General Considerations
Month method
Year function
Day function

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