Date.MonthName

Updated on

Date.MonthName is a Power Query M function that returns the name of the month component for the provided date. An optional culture may also be provided.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Date.MonthName(
   date as any,
   optional culture as nullable text,
) as nullable text
ArgumentAttributeDescription
date
cultureoptionalThe culture argument enables the specification of a Culture code (e.g., “nl-NL” or “en-US”) to align transformations with local formatting conventions. If this argument is omitted, functions default to Culture.Current, which reflects the system’s regional settings. For an exhaustive list of culture codes, check the provided link.

Description

The Date.MonthName function in Power Query M retrieves the month name from a given date, datetime, or datetimezone value. It can return the month name based on the machine’s regional settings or a specified culture code, allowing for output in different languages.

Examples

Let’s explore how to use this function with various examples.

Retrieving the Month Name from a Date Value

To get the month name of a specific date, you can use the following expression:

// Output: "March"
Date.MonthName( #date( 2024, 3, 29 ) )

In this example, the function returns “March” as the month name for the date March 29, 2024.

Specifying the Language with a Culture Parameter

The output of the Date.MonthName function depends on the regional settings of your machine. For instance, if your machine is set to English settings, it will return “March” for the above example. However, if the settings are different, the month name will be in the language of the regional settings.

To ensure that the month name is returned in a specific language, you can use the culture parameter. Here’s how to explicitly specify the language:

// Output: "March"
Date.MonthName( #date( 2024, 3, 29 ), "en-US" )

By including the "en-US" culture code, you ensure that the month name is returned in English, regardless of the machine’s regional settings.

You can also retrieve the month name in a different language by specifying the appropriate culture code. For example, to get the month name in Dutch you can use the “nl-NL” culture code:

// Output: "maart"
Date.MonthName( #date( 2024, 3, 29 ), "nl-NL" )

In this example, the function respects Dutch formatting rules and returns “maart” for the date March 29, 2024. Note that in Dutch, month names are not capitalized.

In the image below, two versions of the Date.MonthName function are applied to the Date column. This comparison clearly shows how the output varies based on the specified culture codes, showing howthe function’s can handle different languages.

Date.MonthName returns the month name of a date value in Power Query M

Applying Date.MonthName to Different Value Types

In addition to using the Date.MonthName function on a date value, you can also apply it to datetime and datetimezone values. Here are some examples:

Date.MonthName( #datetime( 2024, 6, 29, 15, 30, 0 ) )  // Output: June

This example shows how the function retrieves the month name “June” from a datetime value representing June 29, 2024, 15:30:00.

In the next example, the function extracts the month name “June” from a datetimezone value, which includes a timezone offset:

Date.MonthName( #datetimezone( 2024, 6, 29, 15, 30, 0, 2, 0 ) ) // Output: June

Learn more about Date.MonthName in the following articles:

Other functions related to Date.MonthName are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/date-monthname

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy