dateadd()

Adds time (years, months, weeks, days, hours, minutes, and seconds) to the current date-time.

Syntax

dateadd(DATE, "{year|mon|day|hour|min|sec|msec}", INT)
Required Parameters
DATE
Expression that returns the time type.
"{year|mon|day|hour|min|sec|msec}"
Time unit to add to the INT value, enclosed in a pair of double quotes(" "). For the meaning of each unit of time, refer to the table below.
Unit of TimeDescription
yearYear
monMonth
dayDay
hourHour
minMinute
secSecond
msecMillisecond
INT
Integer value to add to the date in the given units.

Usage

json "{}"
| eval time=dateadd(
  date("2013-09-28 11:47:00", "yyyy-MM-dd HH:mm:ss"), "year", 1
)
  => Sun Sep 28 11:47:00 KST 2014

json "{}"
| eval time=dateadd(
  date(date("2013-09-28 11:47:00", "yyyy-MM-dd HH:mm:ss"), "mon", -1
)
  => Wed Aug 28 11:47:00 KST 2013

json "{}"
| eval time=dateadd(
  date("2013-09-28 11:47:00", "yyyy-MM-dd HH:mm:ss"), "day", -3
)
  => Wed Sep 25 11:47:00 KST 2013

json "{}"
| eval time=dateadd(
  date("2013-09-28 11:47:00", "yyyy-MM-dd HH:mm:ss"), "hour", 2
)
  => Sat Sep 28 13:47:00 KST 2013

json "{}" | eval time=dateadd(date(null, "sec", 10) => null

json "{}" | eval time=dateadd("invalid", "sec", 10) => null