title: SQLITE date offset
body: <p>I am trying to replicate the following, which is written in some other flavor of SQL:</p>
  <pre><code>where contact_date &lt;= open_date 
          and contact_date  &gt;= dateadd(days, -30, open_date)
  
  </code></pre>
  <p>And below is my SQLITE query, I have replaced dateadd with SQLITE date analog, but not behaving as expected. I made sure the columns were 'DATE' type, but when I use the date function to make a 30 day offset, it just NULLs out the date.</p>
  <p>Here is my query now:</p>
  <pre><code>SELECT Template, &quot;Outcome Date&quot; as contact_date,&quot;Open Date&quot; as open_date,
  date(&quot;Open Date&quot;,'-30 day') window_date_start
  --cast(&quot;Outcome Date&quot; as integer) contact_date_int, cast(&quot;Open Date&quot; as integer) open_date_int,
  --strftime('%m/%d/%Y %H:%M', &quot;Outcome Date&quot;) as contact_date_strft,   strftime('%m/%d/%Y %H:%M', &quot;Open Date&quot;) as open_date_strft 
  from Emails e
  join Listing l
  on l.&quot;Onovative Id&quot; = e.&quot;Onovative Id&quot;
  where
  contact_date &lt;= open_date
  --and contact_date &gt; date(open_date,'-30 day');   &lt;=== Not working
  </code></pre>
  <p><strong>Output</strong></p>
  <pre><code>Template    contact_date    open_date   window_date_start   &lt;=== cannot really see below, but NULL
  product offer loans auto runoff email   5/20/2020 11:02 6/19/2020 0:00  
  onboarding digital banking email    5/22/2020 11:02 6/24/2020 0:00  
  onboarding digital banking email    5/22/2020 11:02 5/5/2020 0:00   
  product offer loans auto runoff email   5/22/2020 11:02 6/25/2020 0:00  
  onboarding deposits checking 100 email  5/29/2020 11:06 9/24/2020 0:00  
  onboarding deposits checking 100 email  5/29/2020 11:06 5/5/2020 0:00   
  onboarding digital banking email    5/29/2020 11:06 9/9/2020 0:00   
  onboarding digital banking email    5/29/2020 11:06 6/9/2020 0:00   
  product offer loans auto runoff email   5/29/2020 15:12 9/30/2020 0:00
  ...
  </code></pre>
  <p>Anyone know how to offset dates in SQLITE?</p>