Return types

We support a number of different return types:

  • Numbers (floats and integers are both supported)
    = 1 
  • Strings
    = 'Hello world!' 
  • Dates
    = new Date (2014,1,28)
     
  • Boolean
    = true 
  • Array (only arrays of primitive types are allowed, and all elements of the array must be of the same primitive type)
    = [1,1,2,3,5,8] 
  • Object (the values of the object can only be primitive types, and all values of the object must be of the same primitive type)
    = {'first': 10, 'second': 20} 
  • Basic Math
    = 1+1= 5*25= Math.pow(10, 10) 

Streak-specific functions

Working with dates in JavaScript is painful, so we've added a few convenience functions to simplify this. 

Please note that when a date is specified in an example, Streak is expecting a JavaScript date and not a string like "December 31, 2018" to be written there. 

Find the difference between two dates

Streak.hourDifference(date1, date2) - returns the number of hours between two dates

Streak.dayDifference(date1, date2) - returns the number of days between two dates

Streak.weekDifference(date1, date2) - returns the number of weeks between two dates

Streak.monthDifference(date1, date2) - returns the number of months between two dates

Streak.yearDifference(date1, date2) - returns the number of years between two dates

Streak.workdayDifference(date1, date2) - returns the number of non-weekend days between two dates

Functions that add days to a date

Streak.addDays(date1, numDays) - this will add numDays to date1

Streak.addWorkdays(date1, numDays) - this will add numDays worth of workdays to date1

Unsupported functions

Streak's formula functionality is built on Rhino, which is lightly limited in its functionality. You'll find that most common ES5 functions will work, but there is a limit there, too: we do not support XHR or any HTTP requests from formula.

Because of the way formulas are computed, we also advise against using a function like Date.now(), which will not update daily.

Did this answer your question?