DATE_ADD function

The Klipfolio DATE_ADD function adds the given unit amount to the date. You can use negative unit amounts to go backwards in time.

The syntax for the DATE_ADD function is:

DATE_ADD( values , unit , amount )

Parameters

values The data set. Unix time format vector
unit Option to select a unit amount.  Units amounts include: second, minute, hour, day, week, month, quarter, year. selectable option

vector
amount Option to select a negative unit amount. number vector

DATE_ADD example

Let's look at a DATE_ADD function example.

 

A

1 4/1/14
2 4/2/14
3 4/3/14
4 4/4/14
5 4/5/14
6 4/6/14
7 4/7/14
8 4/8/14
9 4/9/14
10 4/10/14
11 4/11/14

The following example is based on the above text from an Excel spreadsheet where today's date is 4/11/14.

SELECT( A:A , ( BETWEEN( DATE( A:A , "M/d/yy" , timezone ) , DATE_ADD( TODAY( ) , day , -6 ) , TODAY( ) ))))      

-> [4/5/14, 4/6/14, 4/7/14, 4/8/14, 4/9/14, 4/10/14, 4/11/14]

Note:The TODAY() function evaluates to Unix time format.

Result: Returns the last 7 days from 4/11/14.

Related links: