Date.StartOfDay Function in Power Query
The Date.StartOfDay function in Power Query (M language) is used to return the start of the day (00:00:00) for a given date or datetime value. It effectively resets the time portion to midnight.
Syntax
Date.StartOfDay(dateTime as any) as any
The function has the parameter:
- dateTime: A value of type
date
,datetime
, ordatetimezone
from which you want to extract the start of the day.
Return Value
- Returns a datetime or datetimezone value representing the start of the day (midnight) for the specified date or datetime.
Key Points
- If the input is:
- date → returns the same date.
- datetime or datetimezone → returns the same date with time set to
00:00:00
.
- The time zone is preserved if the input is
datetimezone
.
Example: Reset time to midnight.
Power Query M
let Source = Date.StartOfDay(#datetime(2025, 8, 24, 15, 45, 30)) in Source
The output of the above code is:
#datetime(2025, 8, 24, 0, 0, 0)
Example:
Power Query M
let Source = Date.StartOfDay(#date(2025, 8, 24)) in Source
The output of the above code is:
#date(2025, 8, 24)
Example: With datetimezone.
Power Query M
let Source = Date.StartOfDay(#datetimezone(2025, 8, 24, 15, 45, 30, 5, 30)) in Source
The output of the above code is:
#datetimezone(2025, 8, 24, 0, 0, 0, 5, 30)