Date.StartOfQuarter Function in Power Query
The Date.StartOfQuarter function in Power Query (M language) returns the first day of the quarter for a given date, datetime, or datetimezone value, with the time component set to midnight (00:00:00).
Syntax
Date.StartOfQuarter( 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 quarter.
Return Value
- Returns a value of the same type (
date
,datetime
, ordatetimezone
) representing the first day of the quarter, with time reset to00:00:00
. - Preserves the time zone if the input is
datetimezone
.
Quarter Calculation
- Q1 → January 1
- Q2 → April 1
- Q3 → July 1
- Q4 → October 1
Example: With a datetime.
Power Query M
let Source = Date.StartOfQuarter(#datetime(2025, 8, 24, 15, 30, 45)) in Source
The output of the above code is:
#datetime(2025, 7, 1, 0, 0, 0)
(Because 24-Aug falls in Q3, which starts on July 1.)
Example: With a date.
Power Query M
let Source = Date.StartOfQuarter(#date(2025, 2, 10)) in Source
The output of the above code is:
#date(2025, 1, 1)
Example: With datetimezone.
Power Query M
let Source = Date.StartOfQuarter(#datetimezone(2025, 10, 15, 12, 0, 0, 05, 30)) in Source
The output of the above code is:
#datetimezone(2025, 10, 1, 0, 0, 0, 05, 30)