DT_ADD Function

Increments the values in a date/time variable by a specified amount.

Usage

    result = DT_ADD(dt_var)

Input Parameters

dt_var — The original date/time variable or array of variables.

Returned Value

result — A date/time variable incremented by the specified amount.

Keywords

Compress — If present and nonzero, excludes predefined weekends and holidays from the result. The default is no compression (0).

Day — Specifies an offset value in days.

Hour — Specifies an offset value in hours.

Minute — Specifies an offset value in minutes.

Month — Specifies an offset value in months.

Second — Specifies an offset value in seconds.

Year — Specifies an offset value in years.

Note: Only one keyword can be specified at a time. You cannot, for example, specify both years and months in a single DT_ADD call. But if you need to add, for example, one day and one hour, you can simply add 25 hours.

Discussion

The DT_ADD function returns a date/time variable containing one or more dates/times that have been offset a specified amount.

The keywords specify how the dates and/or times are incremented (added to). If no keyword is specified, the default increment is one day.

Only positive whole numbers (including zero) can be used with the keywords to specify an increment. Therefore, the smallest unit that can be added to dt_var is one second.

Example

This example shows how to add one day to a date/time variable containing two date/time values.

; Convert two date strings to a date/time variable.
dtarray = STR_TO_DT(['17-03-2000', '8-04-2001'], Date_Fmt=2)
; The date/time variable dtarray contains two dates.
DT_PRINT, dtarray
; 03/17/2000
; 04/08/2001
; Create a new date/time variable dtarray1 that contains
; two dates with one day added to each date.
dtarray1 = DT_ADD(dtarray, /Day)
DT_PRINT, dtarray1
; 03/18/2000
; 04/09/2001

See Also

DT_SUBTRACT,  DT_DURATION

For more information on date/time, see the PV‑WAVE User Guide.