DAX Date & Time - MONTH function



Description

Returns the month as a number from 1 (January) to 12 (December).

Syntax

MONTH (<datetime>) 

Parameters

Sr.No. Parameter & Description
1

datetime

A date in datetime or text format.

Return Value

An integer number from 1 to 12.

Remarks

DAX uses datetime format when working with dates. Dates stored in other formats are converted implicitly.

You can enter the date used as a parameter to the MONTH function in any of the following ways −

  • By typing an accepted datetime format.
  • By providing a reference to a column that contains dates.
  • By using an expression that returns a date.
  • By using a text representation for a date.

DAX MONTH function uses the locale and date/time settings of the client computer to understand the text value in order to perform the conversion. For example,

  • If the current date/time settings represent dates in the format of Month/Day/Year, then the string "1/8/2016" is understood as a datetime value equivalent to 8th January, 2016 and the function returns 1.

  • If the current date/time settings represent dates in the format of Day/Month/Year, the same string would be understood as a datetime value equivalent to 1st August, 2016, and the function returns 8.

    If the text representation of the date cannot be correctly converted to a datetime value, the function returns an error.

Example

= MONTH ("April 5, 2016") returns 4. 
= MONTH ("March 2, 2016 3:45 PM”) returns 3. 
= MONTH (TODAY ()) returns 12 if TODAY () returns 12/16/2016 12:00:00 AM. 
dax_functions_date_time.htm
Advertisements