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(timestamp, component, increment, length, output_format)

where

timestamp

Date-Time

Is the timestamp to be incremented.

component

Alphanumeric

Is the name of the component to be incremented. For a list of valid components, see Date and Time Components For Date and Date-Time Functions.

increment

Integer

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

length

Integer

Is the number of characters returned as the timestamp. Valid values are:

8 for a timestamp in date-time format that includes milliseconds.
10 for a timestamp in date-time format that includes microseconds.

output_format

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