Date.IsInCurrentYear is a Power Query M function that indicates whether the given date(time) value occurs during the current year, 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.IsInCurrentYear( dateTime as any ) as nullable logical
Description
Date.IsInCurrentYear identifies if a given value (of type date, datetime, or datetimezone) is within the current year, as determined by the system’s date and time.
Examples
Let’s explore two straightforward examples to understand how the Date.IsInCurrentYear function works.
Identifying Dates in the Current Year
Let’s say you have a calendar table and you want to add a column that indicates true
for dates within the current year. You can do this using the Date.IsInCurrentYear function on your [Date]
column.
Date.IsInCurrentYear( [Date] ) // Output depends on [Date] column
This expression returns true
for any date in the [Date]
column that is part of the current year.
For example, if today is July 6, 2024, this function will return true
for all rows with dates between January 1, 2024, and December 31, 2024. Here’s a screenshot taken in 2024:
You can see that dates within 2024 are marked with true
for the current year.
Using the Current Date and Time
To test if your system time is in the current year you could use an expression like:
// Output: true
Date.IsInCurrentYear( DateTime.FixedLocalNow() )
Related functions
Other functions related to Date.IsInCurrentYear are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy