Date.EndOfDay

Date

Returns the last moment of the day for the given date or datetime value.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Date.EndOfDay(dateTime as any) as any

Parameters

NameTypeRequiredDescription
dateTimeanyYesA date, datetime, or datetimezone value.

Return Value

anyA 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))
)
Result
LogID
OrderID
Action
Timestamp
DurationMinutes
Notes
1L0011Created1/15/2024 9:30:00 AMnullNew order: Widget A

Example 2: End-of-day for a specific date

#table(
    type table [Result = datetime],
    {{Date.EndOfDay(#date(2024, 3, 15))}}
)
Result
Result
13/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
    )
Applied Steps

The final output — filters the OrderLog table to rows whose Timestamp falls on January 16, 2024.

LogID
OrderID
Action
Timestamp
DurationMinutes
Notes
1L0021Shipped1/16/2024 2:15:00 PM1,725Shipped via express

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks