dateAdd

Adds units of time to a date.

dateAdd(datepart, number, date) → returns Date/Time Object

Argument Reference for the dateAdd function

Name Required Default Description
datepart Yes
  • 'yyyy' - Year
  • 'q' - Quarter
  • 'm' - Month
  • 'y' - Day of year
  • 'd' - Day
  • 'w' - Week day
  • 'ww' - Week
  • 'h' - Hour
  • 'n' - Minute
  • 's' - Second
  • 'l' - Millisecond
number Yes The number of dateparts to add or subtract from the provided date.
Negative integers move the date into the past, positive into the future.
date Yes
  • now()
  • createDate(2014,3,15)
  • "{ts '2014-03-15 23:59:59'}"
  • '3/15/2014'
  • '2014-03-15'

Examples sample code invoking the dateAdd function


Add Weeks

Here we're adding 8 weeks to the date August 3rd, 2014.

my_new_date = dateAdd('ww', 8, '8/3/2014');

Expected Result: {ts '2014-09-28 00:00:00'}


Fork me on GitHub