title: Query recent records with separate date and time fields
body: <p>I'm working with a table in SAP Advantage with separate date and time fields. I want to find records with a date and time within the last 5 minutes.</p>
  
  <p>This works 99% of the time:</p>
  
  <pre><code>SELECT
      *
  FROM
      table_name
  WHERE 
      TIMESTAMPDIFF(SQL_TSI_DAY, date_field, CURRENT_TIMESTAMP()) &lt; 1
  AND
      TIMESTAMPDIFF(SQL_TSI_MINUTE, time_field, CURRENT_TIMESTAMP()) &lt; 5
  </code></pre>
  
  <p>However, this won't work around midnight.  For instance, at 12:00AM, any records created at 11:57PM the previous day won't match the filter.</p>
  
  <p>Any idea to do this?  Thanks!</p>
  
  <p>Sample image of data.  Based on this data, at 7/12/19 at 12:01AM, I'd like to return the last 2 rows.</p>
  
  <p><a href="https://i.stack.imgur.com/kcajD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kcajD.png" alt="enter image description here"></a></p>
  
  <pre><code>Created: 7/11/2019 22:54:43
  
  Item EmpNo      LastName             FirstName       date_field time_field
  --------------------------------------------------------------------------
  1          2 Nelson               Roberto         7/11/2019  21:00:00  
  2          4 Young                Bruce           7/11/2019  22:00:00  
  3          5 Lambert              Kim             7/11/2019  23:00:00  
  4          8 Johnson              Leslie          7/11/2019  23:56:00  
  5          9 Forest               Phil            7/12/2019  00:00:00  
  </code></pre>