DateSerial
Returns date for a specified year, month, and day.
Syntax
DateSerial(Year_Numeric_Expression, Month_Numeric_Expression, Day_Numeric_Expression)
Arguments
| Year_Numeric_Expression | Integer expression for a year. |
|---|---|
| Month_Numeric_Expression | Integer expression for a month. |
| Day_Numeric_Expression | Integer expression for a day of the month. |
Examples
Convert specific numbers to a date
The example below returns the date matching 31st December, 2025
DateSerial(2023, 12, 31)
Generate the date relative to the current date
The following example shows a calculated member in the Time dimension Weekly hierarchy to get all full weeks from the last three months, including the current month:
Aggregate(
[Time.Weekly].[Week].DateMembersBetween(
DateSerial(Year(Now()), Month(Now()) - 2, -6),
DateSerial(Year(Now()), Month(Now()) + 1, 0)
)
)
Where:
DateSerial(Year(Now()), Month(Now())-2, -6)returns 7 days before the end of the 2 months ago to include a week where months do not start with the first day of the week.DateSerial(Year(Now()), Month(Now())+1, 0)returns the last day of the current month.
See the report example, Most active days by weeks and weekdays in our Demo account. The calculated member Last three months in dimension Time uses the formula above. The report uses this calculated member and several other calculated members in the Time dimensions as a selection option on Pages.