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 FilterExample
exact date rangeq = filter q by year('CloseDate')=='2018';
specific date rangeq = filter q by year('CloseDate') in [2017..2018];
relative date rangeSee the examples below.

Examples of relative date range filters:

1q = filter q by CloseDate in ["last 2 years"];
2q = filter CloseDate in ["current fiscal_year".."current day"];
3q = filter CloseDate in ["2 fiscal_years ago".."current day"];

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.

Note

You can use these relative date keywords:

  • current day
  • n day(s) ago
  • n day(s) ahead
  • current week
  • n week(s) ago
  • n week(s) ahead
  • current month
  • n month(s) ago
  • n month(s) ahead
  • current quarter
  • n quarter(s) ago
  • n quarter(s) ahead
  • current fiscal_quarter
  • n fiscal_quarter(s) ago
  • n fiscal_quarter(s) ahead
  • current year
  • n year(s) ago
  • n year(s) ahead
  • current fiscal_year
  • n fiscal_year(s) ago
  • n fiscal_year(s) ago

See Also