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
Argument | Attribute | Description |
---|---|---|
date | ||
culture | optional | The 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.
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
Related articles
Learn more about Date.MonthName in the following articles:
- Create Date Table with Dynamic Language in Power Query
Want your Date Table in Multiple Languages? This post explains how to make your calendar dynamic to support any language or culture. » Read more - Create Date Table or Calendar in Power Query M
Learn how to create a dynamic calendar table in Power Query’s M language. Build your custom columns and claim your free Date Table Script. » Read more
Related functions
Other functions related to Date.MonthName are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy