DateTime.Date

DateTime

Returns the date part from a datetime value.

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

Syntax

DateTime.Date(dateTime as any) as nullable date

Parameters

NameTypeRequiredDescription
dateTimeanyYesThe datetime value to extract the date from.

Return Value

dateThe date component of the given datetime.

Remarks

DateTime.Date extracts the date component from a datetime or datetimezone value, discarding the time portion. If the input is null, the function returns null.

Examples

Example 1: Extract date from OrderLog Timestamp

Table.AddColumn(
    Table.SelectColumns(
        Table.FirstN(OrderLog, 5),
        {"LogID", "Timestamp"}
    ),
    "DateOnly", each DateTime.Date([Timestamp]), type date
)
Result
LogID
Timestamp
DateOnly
1L0011/15/2024 9:30:00 AM1/15/2024
2L0021/16/2024 2:15:00 PM1/16/2024
3L0031/18/2024 11:00:00 AM1/18/2024
4L0041/20/2024 8:45:00 AM1/20/2024
5L0052/1/2024 4:20:00 PM2/1/2024

Example 2: Extract date from a scalar datetime

#table(
    type table [DateTime = datetime, DateOnly = date],
    {{#datetime(2024, 3, 15, 14, 30, 0), DateTime.Date(#datetime(2024, 3, 15, 14, 30, 0))}}
)
Result
DateTime
DateOnly
13/15/2024 2:30:00 PM3/15/2024

Compatibility

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