DateTime.Date

Updated on

DateTime.Date is a Power Query M function that returns the date component of the given date, datetime, or datetimezone value.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

DateTime.Date( dateTime as any ) as nullable date

Description

DateTime.Date returns the date component of the given dateTime argument, which can be of type date, datetime, or datetimezone. The function returns null when provided with a null value.

Examples

You can extract a date value from a datetime value in Power Query M. For instance, consider the datetime value December 14, 2024, 13:04. Here’s how you can extract the date part:

// Output: #date( 2024, 12, 14)
DateTime.Date( #datetime( 2024, 12, 14, 13, 4, 0 ) )

When you apply this function to a datetime column, it will transform all datetime values to date values, as shown below:

DateTime.Date extracts date from datetime value in power query m

Applying DateTime.Date to DateTimeZone Values

The DateTime.Date function also works on datetimezone values. Here’s an example how:

// Output: #date( 2024, 6, 20 )
DateTime.Date( #datetime( 2024, 6, 20, 10, 30, 0 ) )

Applying DateTime.Date to Date Values

Similarly, date values are supported. You might wonder about usefulness of applying the DateTime.Date function to a date value since it returns the date itself. Here’s an example:

// Output: #date( 2024, 1, 31 )
DateTime.Date( #date( 2024, 1, 31 ) )

Other functions related to DateTime.Date are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/datetime-date