MONTH

The function MONTH returns the value of the month in a Date or DateTime.

This function takes either a single DateTime or a single Date as input. It then returns a Number: the value of the month in the given Time or a DateTime.

Declaration

MONTH(datetime) -> month
MONTH(date) -> month

 

Parameters

datetime (type: DateTime)
Any DateTime.
This is what describes the month value that the MONTH function will return.

date (type: Date)
Any Date.
This is what describes the month value that the MONTH function will return.

Return Values

month (type: Number)
The month value from the given Date or DateTime.

Examples

Assume the first example has access to the following DateTime value:

example_date_and_time = {  
 "date": {  
  "day": 1,  
  "month": 4,  
  "year": 2021  
 },  
 "time": {  
  "hour": 16,  
  "minute": 14,  
  "second": 38,  
  "millisecond": 0  
 },  
 "timeZone": "UTC"  
}

The following example retrieves the month described in the DateTime example_date_and_time. Note how the output matches the year given in the above variable:

MONTH(example_date_and_time) = 4

The above example demonstrates how the MONTH function behaves when given a DateTime as input. In order to further establish how the MONTH function behaves when given a date as input, assume the last example has access to the following date value:

example_date = {  
 "day": 1,  
 "month": 4,  
 "year": 2021  
}

The following example retrieves the month described in the DateTime example_date. Note that the date described in example_date is identical to the date described in example_date_and_time, and that MONTH returns the same value when given either as input:

MONTH(example_date) = 4