Date.EndOfDay
DateReturns the last moment of the day for the given date or datetime value.
Syntax
Date.EndOfDay(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 23:59:59.9999999 on the given day.
Remarks
Date.EndOfDay returns the very last instant of the day — 23:59:59.9999999 — as a datetime (or datetimezone, if the input is a datetimezone). When passed a plain date, the result is a datetime. This is useful for building inclusive upper-bound filters when working with datetime columns, ensuring that events at any time on that day are captured.
A common pattern is combining Date.StartOfDay and Date.EndOfDay to create an inclusive date range: [EventTime] >= Date.StartOfDay(startDate) and [EventTime] <= Date.EndOfDay(endDate). This avoids the off-by-one errors that occur when filtering datetimes with a date-only boundary.
When passed a datetimezone, the output preserves the timezone offset and adjusts only the time components. The function does not convert across timezones — use DateTimeZone.SwitchZone if you need timezone conversion before applying the day boundary.
Examples
Example 1: Filter log entries on or before the end of January 15
Table.SelectRows(
OrderLog,
each [Timestamp] <= Date.EndOfDay(#date(2024, 1, 15))
)LogID | OrderID | Action | Timestamp | DurationMinutes | Notes | |
|---|---|---|---|---|---|---|
| 1 | L001 | 1 | Created | 1/15/2024 9:30:00 AM | null | New order: Widget A |
Example 2: End-of-day for a specific date
#table(
type table [Result = datetime],
{{Date.EndOfDay(#date(2024, 3, 15))}}
)Result | |
|---|---|
| 1 | 3/15/2024 11:59:59 PM |
Example 3: Build an inclusive date range filter
let
TargetDate = #date(2024, 1, 16),
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 16, 2024.
LogID | OrderID | Action | Timestamp | DurationMinutes | Notes | |
|---|---|---|---|---|---|---|
| 1 | L002 | 1 | Shipped | 1/16/2024 2:15:00 PM | 1,725 | Shipped via express |