dateAdd

Adds units of time to a date.

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

dateAdd Function Argument Reference

Name Required Default Description
datepart Yes

Example Values:

  • '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

Example Values:

  • now()
  • CreateDate(2014,3,15)
  • "{ts '2014-03-15 23:59:59'}"
  • '3/15/2014'
  • '2014-03-15'

dateAdd Examples


Add Weeks

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

my_new_date = DateAdd('w', 8, '8/3/2014');

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


Fork me on GitHub