DTADD: Incrementing a Date or Date-Time Component

How to:

Reference:

Given a date in standard date or date-time format, DTADD returns a new date after adding the specified number of a supported component. The returned date format is the same as the input date format.


Top of page

x
Syntax: How to Increment a Date or Date-Time Component
DTADD(date, component, increment)

where:

date

Date or date-time

Is the date or date-time value to be incremented.

component

Keyword

Is the component to be incremented. Valid components (and acceptable values) are:

  • YEAR (1-9999)
  • QUARTER (1-4)
  • MONTH (1-12)
  • WEEK (1-53). This is affected by the WEEKFIRST setting.
  • DAY (of the Month, 1-31)
  • HOUR (0-23)
  • MINUTE (0-59)
  • SECOND (0-59)
increment

Integer

Is the value (positive or negative) to add to the component.



Example: incrementing the DAY Component of a Date

The following request against the WF_RETAIL data source adds three days to the employee date of birth:

DEFINE FILE WF_RETAIL
NEWDATE/YYMD = DTADD(DATE_OF_BIRTH, DAY, 3);
MGR/A3 = DIGITS(ID_MANAGER, 3);
END
TABLE FILE WF_RETAIL
SUM MGR NOPRINT DATE_OF_BIRTH NEWDATE
BY MGR
ON TABLE SET PAGE NOPAGE
END

The output is:


Top of page

x
Reference: Usage Notes for DTADD

WebFOCUS