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.
This works 99% of the time:
SELECT
*
FROM
table_name
WHERE
TIMESTAMPDIFF(SQL_TSI_DAY, date_field, CURRENT_TIMESTAMP()) < 1
AND
TIMESTAMPDIFF(SQL_TSI_MINUTE, time_field, CURRENT_TIMESTAMP()) < 5
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.
Any idea to do this? Thanks!
Sample image of data. Based on this data, at 7/12/19 at 12:01AM, I'd like to return the last 2 rows.
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