Filter By Date
You can filter results by DateTime and DateOnly fields. Filters can include exact dates, specific date ranges, or relative date ranges.
| Type of Filter | Example |
|---|---|
| exact date range | q = filter q by year('CloseDate')=='2018'; |
| specific date range | q = filter q by year('CloseDate') in [2017..2018]; |
| relative date range | See the examples below. |
Examples of relative date range filters:
Filter with binary comparison operators ==, !=, <, >, <=, and >= only after your query’s foreach statement, post-projection. For example, include the filter q = filter q by CloseDate >= "2014-01-01" post-projection. If you include it pre-projection, the query throws an error. The inability to include filters that use these comparison operators pre-projection is a limitation of the beta release.
You can filter pre- and post-projection with the IN comparison operator. The like and matches operators are not supported for time zone-enabled DateTime and DateOnly fields.
You can use these relative date keywords:
current dayn day(s) agon day(s) aheadcurrent weekn week(s) agon week(s) aheadcurrent monthn month(s) agon month(s) aheadcurrent quartern quarter(s) agon quarter(s) aheadcurrent fiscal_quartern fiscal_quarter(s) agon fiscal_quarter(s) aheadcurrent yearn year(s) agon year(s) aheadcurrent fiscal_yearn fiscal_year(s) agon fiscal_year(s) ago
See Also