Date Filters - Vanilla Success
<main> <article class="userContent"> <p>There are a lot of endpoints that allow you to filter on a date such as the date that a record was inserted or updated. In these cases you can filter based on a range of values.</p><h2 data-id="date-formats">Date Formats</h2><p>The most simple filter is just specifying a date and checking for equality. When you specify a date use the <a href="https://www.ietf.org/rfc/rfc3339.txt" rel="nofollow noreferrer ugc">RFC339</a> format. Here are some examples:</p><pre class="code codeBlock" spellcheck="false" tabindex="0">2018-12-25 1985-04-12T23:20:50.52Z 1996-12-19T16:39:57-08:00 2018-12-25 </pre><p>This is a flexible, unambiguous format that allows you to specify a date, date/time, and also specify timezones.</p><h2 data-id="basic-date-operations">Basic Date Operations</h2><p>Usually, you don’t want to filter on an exact date, but rather specify an operation. To do this put one of the <code class="code codeInline" spellcheck="false" tabindex="0">=,>,<,>=,<=</code> operations before the date.</p><pre class="code codeBlock" spellcheck="false" tabindex="0">>2013-01-24 <=2019-12-31T23:59:59Z </pre><h2 data-id="date-ranges">Date Ranges</h2><p>You can also filter based on date ranges. To do this you put two dates between brackets, seperated by a comma. You can use square brackets <code class="code codeInline" spellcheck="false" tabindex="0">[]</code> for inclusive ranges and round brackets <code class="code codeInline" spellcheck="false" tabindex="0">()</code> fore exclusive ranges. You can also mix and match brackets.</p><pre class="code codeBlock" spellcheck="false" tabindex="0">[2013-03-04,2013-03-04T23:20:50.52Z] [2018-01-01,2019-01-01) // anything in 2019 </pre><h2 data-id="date-filters-must-be-encoded">Date Filters Must Be Encoded</h2><p>Most date filters are supplied in the query string which means they have to be encoded just like any other query string parameter. Most dates will work regardless of encoding, but it is considered a best practice to always encode.</p> </article> </main>