Date.IsInYearToDate

Updated on

Date.IsInYearToDate is a Power Query M function that indicates whether the given date(time) value occurs during the current year and is on or before the current day, 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.IsInYearToDate( dateTime as any ) as nullable logical

Description

Date.IsInNextNYears evaluates if a given value (of type date, datetime, or datetimezone) is within the next specified number of years from the current system date and time, excluding the current year. It includes a years argument.

Examples

Let’s explore two straightforward examples to understand how the Date.IsInYearToDate function works.

Checking Dates in a Calendar Table

Suppose you have a calendar table and you want to add a column that indicates true for dates that fall within the current year up to today’s date. You can do this using the Date.IsInYearToDate function on your [Date] column.

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

This expression returns true for any date in the [Date] column that falls within the current year up to and including today’s date.

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

Example of how to use the Date.IsInYearToDate function in Power Query M

You can see that dates within the current year up to July 7, 2024, are marked with true.

Using the Current Date and Time

To test if today’s date is within the current year to date, you can use the following expression:

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

Other functions related to Date.IsInYearToDate are:

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

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