HADD: Incrementing a Date-Time Value

How to:

The HADD function increments a date-time value by a given number of units.


Top of page

x
Syntax: How to Increment a Date-Time Value
HADD(datetime, 'component', increment, length, output)

where:

datetime

Date-time

Is the date-time value to be incremented.

component

Alphanumeric

Is the name of the component to be incremented enclosed in single quotation marks. For a list of valid components, see Arguments for Use With Date and Time Functions.

Note: WEEKDAY is not a valid component for HADD.

increment

Integer

Is the number of units (positive or negative) by which to increment the component.

length

Integer

Is the number of characters returned. Valid values are:

8 indicates a date-time value that includes one to three decimal digits (milliseconds).

10 indicates a date-time value that includes four to six decimal digits (microseconds).

12 indicates a date-time value that includes seven to nine decimal digits (nanoseconds).

output

Date-time



Example: Incrementing a Date-Time Value

The following example increments thirty months to some specific date-time in the past

HADD(DT(2001/09/11 08:54:34), 'MONTH', 30, 8, 'HYYMDS')

and returns the timestamp 2004/03/11 08:54:34.00.


iWay Software