I have a query that picks up the last_update_date in the format -
person_number last_update_date location
10 2021-06-10T16:02:50.222 00:00 Peru
11 2021-06-10T16:03:50.222 00:00 Argentine
query-
select person_number,
last_update_Date,
location
I want to add a where clause in this so that the query picks up only the last 15 minutes chanegs in the last_update_date. i.e. all teh records that has the timestamp for last 15 minutes.
is there a way to do this ?
CodePudding user response:
Check if date column is between sysdate(this is current time) and sysdate (1/1440*15)(this is current time 15 minutes)
select person_number,
last_update_Date,
location,
sysdate,
sysdate (1/1440*15)
from tab1
where last_update_date between sysdate and sysdate (1/1440*15)
Here is a demo made at 2022-06-10 20:35:00
CodePudding user response:
Use an INTERVAL
:
SELECT person_number,
last_update_Date,
location
FROM table_name
WHERE last_update_date BETWEEN SYSDATE - INTERVAL '15' MINUTE
AND SYSDATE