Date.IsInCurrentMonth

Updated on

Date.IsInCurrentMonth is a Power Query M function that indicates whether the given date(time) value occurs during the current month, as determined by the system. The function returns a boolean value (true or false).

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

Syntax

Date.IsInCurrentMonth( dateTime as any ) as nullable logical

Description

Date.IsInCurrentMonth identifies if the given value (of type date, datetime, or datetimezone) is within the current month, as determined by the system’s date and time.

Examples

Let’s look at two simple examples to understand how Date.IsInCurrentMonth works.

Identifying Dates in the Current Month

Let’s say you have a date table and want to add a column that shows true for dates that are in the current month. You can do this with the Date.IsInCurrentMonth function applied to your [Date] column.

Date.IsInCurrentMonth( [Date] ) // Output depends on [Date] column

This expression will return true for any date in the [Date] column that falls within the current month.

For example, if today is July 7, 2024, this function will mark true for all rows with dates between July 1, 2024, and July 31, 2024. Here’s a screenshot showing this:

How to use the Date.IsInCurrentMonth Function in Power Query M

You can see that dates within July 2024 are marked with true for the current month.

Using the Current Date and Time

You can also use Date.IsInCurrentMonth to check if the current date and time falls within the current month. You can do it using the DateTime.FixedLocalNow function, which gets the current date and time.

// Output: true
Date.IsInCurrentMonth( DateTime.FixedLocalNow() )

Here, DateTime.FixedLocalNow gets the current date and time. The Date.IsInCurrentMonth function then checks if this date and time falls within the current month, which will always be true for dates within the same month as today.

Other functions related to Date.IsInCurrentMonth are:

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

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