Use the asDateRange() serialization function to bind filters based on date ranges. You can create filters using absolute or relative date ranges.
If the input data is a one-dimensional array with two elements:
And both elements are numbers, CRM Analytics assumes the numbers are epoch times. [1016504910000, 1016504910000] results in fieldName in [dateRange([2002,3,19], [2010,8,12])].
Otherwise, the first element is used as the minimum and the second element is used as the maximum. ["current day", "1 month ahead"] results in fieldName in ["current day".."1 month ahead"]. If one of the elements is null, the date range is open-ended. ["1 month ago", null] results in fieldName in ["1 month ago"..].
If the input data is a two-dimensional array where the outer array has two elements:
And both nested arrays have two elements, CRM Analytics assumes the data is in the relative date array format. [["year", -2], ["year", 1]] results infieldName in ["2 years ago".."1 year ahead"].
And both nested arrays have 3 elements, the nested arrays are passed to the SAQL dateRange() function. [[2015, 2, 1], [2016, 2, 1]] results in fieldName in [dateRange([2015,2,1], [2016,2,1])].
If the input data is null, the result is fieldName in all, which doesn’t filter anything.
Binding to a Date Filter Widget
For instance, let’s say you make a selection in a date widget that returns this absolute date range (in epoch format).
1[{min: 1016504910000, max: 1281655993000}]
You can create a filter using the returned selection data.
After CRM Analytics evaluates the binding, the filter becomes:
1q = filter q by date(year, month, day)in["1 year ago".."current day"];
You can also create an open-ended range filter by specifying null as one of the relative date keywords in the source query. The bound filter is as shown.