invantive documentationpart of invantive cloud
Invantive Support ForumsLog In / Sign Up

DATEADD

Syntax

%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> DATEADD[DATEADD]:::quoted
    DATEADD --> End((END))

Purpose

The DATEADD SQL function adds a quantity of time to a date.

Parameters:

  • Interval (varchar2): the date interval to be added, chosen from year, yyyy, yy, quarter, qq, q, month, mm, m, day, dy, y, week, ww, wk, hour, hh, minute, mi, n, second, ss, s, millisecond and ms.
  • Number (int32): the quantity of interval duration to add.
  • Date (datetime): the date to which the interval should be added.

Returns: the date with the number of intervals added as datetime.

Examples

The following example adds 3 weeks to a date:

select dateadd('week', 3, to_date('19870315', 'YYYYMMDD'))

-------------------
05-04-1987 00:00:00

The following example adds 7 days to a date:

select dateadd('y', 7, to_date('19870315', 'YYYYMMDD'))

-------------------
22-03-1987 00:00:00