DAX stores dates as a DateTime data type. This format uses a floating-point number internally, wherein the integer corresponds to the number of days since December 30, 1899, and the decimal part identifies the fraction of the day. Hours, minutes, and seconds are converted to decimal fractions of a day. Thus, the following expression returns the current date plus one day (exactly 24 hours):
= TODAY () + 1
The result is the date of tomorrow, at the time of the evaluation. If one only needs to take the date part of a DateTime, they should use INT or TRUNC to get rid of the decimal part.
In Power BI, the user interface shows two additional data types: Date and Time. However, they are both stored as DateTime. In fact, Date and Time only show the integer or the decimal part of the DateTime, respectively.
The first date officially supported by DAX is March 1, 1900. Date calculations executed on time periods prior to that date might lead to errors and should be considered as inaccurate.
A DateTime value can be specified as a literal by using the prefix dt before a string with one of the following formats:
- dt”YYYY-MM-DD hh:mm:ss”
For example, DATE ( 2023, 5, 19 ) corresponds to dt”2023-05-19″.
Contributors: Alberto Ferrari, Marco Russo, Kenneth Barber, Sergio Murru