DateTime.Date
DateTimeReturns the date part from a datetime value.
Syntax
DateTime.Date(dateTime as any) as nullable dateParameters
| Name | Type | Required | Description |
|---|---|---|---|
dateTime | any | Yes | The datetime value to extract the date from. |
Return Value
date — The 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 | |
|---|---|---|---|
| 1 | L001 | 1/15/2024 9:30:00 AM | 1/15/2024 |
| 2 | L002 | 1/16/2024 2:15:00 PM | 1/16/2024 |
| 3 | L003 | 1/18/2024 11:00:00 AM | 1/18/2024 |
| 4 | L004 | 1/20/2024 8:45:00 AM | 1/20/2024 |
| 5 | L005 | 2/1/2024 4:20:00 PM | 2/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 | |
|---|---|---|
| 1 | 3/15/2024 2:30:00 PM | 3/15/2024 |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks