The DAY function returns the day of a date as an integer from 1 to 31.
DAY(
date
)
- date: Value corresponding to a date in datetime format, or text representing a date.
The DAY function returns an integer in the range 1-31.
The date passed to the function as an argument can come from an expression or, as mentioned, from a text that represents a date. This date must be a unique value (the function, once contextualized, does not accept a column of dates as input).
Even though the DAY function requires a datetime type argument, it can also receive a real number (in which the integer part is considered as a reference to the date and the decimal part as a reference to the time) in general format or in any other format (date and time or other). For this reason, the DAY function takes both a time and a date as an argument. In the case of receiving an hour as an argument (without reference to a specific date), December 30, 1899 is assumed. Thus, the function
Day = DAY("15:13:43")
...will return 30.
The date argument can be provided by a date/time creation function, by a function that returns a date/time value, by a reference to a column containing date/time values, or as a text string containing the value of date/time from which to extract the day. In the latter case, the DAY function will use the regional configuration and the date and time settings of the client computer in order to interpret the text from which to extract the correct value. In this way, the following functions (which receive the same real number as an argument with a different format), will return the same value: 15.
Day = DAY("10/15/2016 11:9:14")
Day = DAY(42658.4230787037)
However, the interpretation of a date such as "8/10/2016" will depend on the locale. If it represents dates in "day/month/year" format, it will be interpreted as August 10, 2016. On the contrary, if it represents dates in "month/day/year" format, it will be interpreted as October 8 of 2016.
The value returned by this function will always be the one corresponding to the Gregorian calendar. More information about this calendar can be found on this Wikipedia page.
The following example extracts (as a new column) the day from the field containing the date and time of each sale:
...however, in the same scenario, if we try to create a measure to extract the same information, we see how Power BI does not allow us to include that column as an argument: