Give an expression to add 4 months to the date 014-03-12?
beginnerAnswer
`DATEADD('month', 4, [Date])` — the arguments are the date part, the interval to add, and the date to shift.
For a literal rather than a field, wrap it: `DATEADD('month', 4, #2014-03-12#)`, which returns 12 July 2014. Tableau uses `#` around date literals.
The same function handles other parts by swapping the first argument — `'day'`, `'week'`, `'quarter'`, `'year'` — and a negative interval shifts backwards.
The function it gets confused with is `DATEDIFF`, which measures the gap between two dates rather than shifting one. `DATEADD` moves a date, `DATEDIFF` measures between dates, and `DATEPART` extracts a component from one.
Related questions