Date.StartOfYear Function in Power Query
The Date.StartOfYear function in Power Query (M language) returns the first day of the year for a given date, datetime, or datetimezone value, with the time component set to midnight (00:00:00).
Syntax
Date.StartOfYear( dateTime as any ) as any
The function has the following parameter:
- dateTime: A value of type
date
,datetime
, ordatetimezone
for which you want the start of the year.
Return Value:
- Returns a value of the same type (
date
,datetime
, ordatetimezone
) representing January 1st of that year. - Preserves the time zone if the input is
datetimezone
.
Example: With a datetime.
Power Query M
let Source = Date.StartOfYear(#datetime(2025, 8, 24, 15, 30, 45)) in Source
The output of the above code is:
#datetime(2025, 1, 1, 0, 0, 0)
Example: With a date.
Power Query M
let Source = Date.StartOfYear(#date(2025, 5, 10)) in Source
The output of the above code is:
#date(2025, 1, 1)
Example: With datetimezone.
Power Query M
let Source = Date.StartOfYear(#datetimezone(2025, 8, 24, 10, 0, 0, 05, 30)) in Source
The output of the above code is:
#datetimezone(2025, 1, 1, 0, 0, 0, 5, 30)