|
| 1 | +--- |
| 2 | +description: "Learn more about: DATEADD" |
| 3 | +title: "DATEADD function (DAX)" |
| 4 | +--- |
| 5 | +# DATEADD |
| 6 | + |
| 7 | +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] |
| 8 | + |
| 9 | +Returns a table that contains a column of dates, shifted either forward or backward in time by the specified number of intervals from the dates in the current context. |
| 10 | + |
| 11 | +## Syntax |
| 12 | + |
| 13 | +```dax |
| 14 | +DATEADD(<dates>,<number_of_intervals>,<interval>) |
| 15 | +``` |
| 16 | + |
| 17 | +### Parameters |
| 18 | + |
| 19 | +|Term|Definition| |
| 20 | +|--------|--------------| |
| 21 | +|`dates`|A column that contains dates.| |
| 22 | +|`number_of_intervals`|An integer that specifies the number of intervals to add to or subtract from the dates.| |
| 23 | +|`interval`|The interval by which to shift the dates. The value for interval can be one of the following: `year`, `quarter`, `month`, `day`| |
| 24 | + |
| 25 | +## Return value |
| 26 | + |
| 27 | +A table containing a single column of date values. |
| 28 | + |
| 29 | +## Remarks |
| 30 | + |
| 31 | +The `dates` argument can be any of the following: |
| 32 | + |
| 33 | +- A reference to a date/time column, |
| 34 | + |
| 35 | +- A table expression that returns a single column of date/time values, |
| 36 | + |
| 37 | +- A Boolean expression that defines a single-column table of date/time values. |
| 38 | + |
| 39 | + > [!NOTE] |
| 40 | + > Constraints on Boolean expressions are described in the topic, [CALCULATE function](calculate-function-dax.md). |
| 41 | +
|
| 42 | +- If the number specified for `number_of_intervals` is positive, the dates in `dates` are moved forward in time; if the number is negative, the dates in `dates` are shifted back in time. |
| 43 | + |
| 44 | +- The `interval` parameter is an enumeration, not a set of strings; therefore values should not be enclosed in quotation marks. Also, the values: `year`, `quarter`, `month`, `day` should be spelled in full when using them. |
| 45 | + |
| 46 | +- The result table includes only dates that exist in the `dates` column. |
| 47 | + |
| 48 | +- If the dates in the current context do not form a contiguous interval, the function returns an error. |
| 49 | + |
| 50 | +- [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] |
| 51 | + |
| 52 | +## Example - Shifting a set of dates |
| 53 | + |
| 54 | +The following formula calculates dates that are one year before the dates in the current context. |
| 55 | + |
| 56 | +```dax |
| 57 | += DATEADD(DateTime[DateKey],-1,year) |
| 58 | +``` |
| 59 | + |
| 60 | +## Special behavior |
| 61 | + |
| 62 | +When selection includes last two days of month, it will use "extension" semantics and will includes day till end of month. For example, when Feb 27 and 28 of 2013 are included and a month is added, it will get March 27 to 31. |
| 63 | + |
| 64 | +This behavior will only happen when last two days of month are included. If only Feb 27 is selected, it will go to March 27. |
| 65 | + |
| 66 | +```dax |
| 67 | += DATEADD(DateTime[DateKey], 1, month) |
| 68 | +``` |
| 69 | + |
| 70 | +## Related content |
| 71 | + |
| 72 | +[Time intelligence functions](time-intelligence-functions-dax.md) |
| 73 | +[Date and time functions](date-and-time-functions-dax.md) |
0 commit comments