Date.StartOfDay
DateReturns the first moment of the day (midnight) for the given date or datetime value.
Syntax
Date.StartOfDay(dateTime as any) as anyParameters
| Name | Type | Required | Description |
|---|---|---|---|
dateTime | any | Yes | A date, datetime, or datetimezone value. |
Return Value
any — A datetime or datetimezone value representing 00:00:00 on the given day.
Remarks
Date.StartOfDay returns the very first instant of the day — 00:00:00 — as a datetime. When passed a plain date, it returns a datetime with the time component set to midnight. When passed a datetimezone, it preserves the timezone offset and sets only the time components to midnight. This is useful for building inclusive lower-bound date range filters.
A common pattern is combining Date.StartOfDay and Date.EndOfDay to create an inclusive day range: [EventTime] >= Date.StartOfDay(start) and [EventTime] <= Date.EndOfDay(end). This avoids filtering bugs that arise from comparing a datetime column against a bare date value.
Note that Date.StartOfDay applied to a datetime truncates to midnight of that datetime's day. If the input is already 00:00:00, the output is unchanged. To truncate a datetime to a specific hour instead of midnight, use Time.StartOfHour.
Examples
Example 1: Filter log entries on or after the start of a specific day
Table.SelectRows(
OrderLog,
each [Timestamp] >= Date.StartOfDay(#date(2024, 1, 16))
)LogID | OrderID | Action | Timestamp | DurationMinutes | Notes | |
|---|---|---|---|---|---|---|
| 1 | L002 | 1 | Shipped | 1/16/2024 2:15:00 PM | 1,725 | Shipped via express |
| 2 | L003 | 2 | Created | 1/18/2024 11:00:00 AM | null | New order: Gadget B |
| 3 | L004 | 2 | Shipped | 1/20/2024 8:45:00 AM | 2,745 | Standard shipping |
| 4 | L005 | 3 | Created | 2/1/2024 4:20:00 PM | null | New order: Widget C |
| 5 | L006 | 3 | Cancelled | 2/2/2024 10:05:00 AM | 1,065 | Customer request |
| 6 | L007 | 4 | Created | 2/10/2024 1:00:00 PM | null | New order: Gadget D |
| 7 | L008 | 4 | Shipped | 2/12/2024 9:30:00 AM | 2,670 | Shipped via express |
Example 2: Return the start-of-day datetime for March 15, 2024
#table(
type table [Result = datetime],
{{Date.StartOfDay(#date(2024, 3, 15))}}
)Result | |
|---|---|
| 1 | 3/15/2024 12:00:00 AM |
Example 3: Build an inclusive date range filter using StartOfDay and EndOfDay
let
TargetDate = #date(2024, 1, 15),
RangeStart = Date.StartOfDay(TargetDate),
RangeEnd = Date.EndOfDay(TargetDate)
in
Table.SelectRows(
OrderLog,
each [Timestamp] >= RangeStart and [Timestamp] <= RangeEnd
)The final output — filters the OrderLog table to rows whose Timestamp falls on January 15, 2024.
LogID | OrderID | Action | Timestamp | DurationMinutes | Notes | |
|---|---|---|---|---|---|---|
| 1 | L001 | 1 | Created | 1/15/2024 9:30:00 AM | null | New order: Widget A |