Count entries created recently in an oracle database

We will base the logic around sysdate which returns the current datetime, from which we substract units. For example for the last day from now use sysdate - 1 (defaults to day) and compare with the timestamp column (in this case CREATED_AT) :

select count(*)
from PARTNER
WHERE CREATED_AT > (sysdate - 1)

-- last 2 days would be
select count(*)
from PARTNER
WHERE CREATED_AT > (sysdate - 2)

From the last hour, respectively last two hours use the following commands, where 1/24 is the unit for hour:

-- last hour
select count(*)
from PARTNER
WHERE CREATED_AT > (sysdate - 1)

-- last 2 hours
select count(*)
from PARTNER
WHERE CREATED_AT > (sysdate - 2/24)

Shared with from Codever. 👉 Use the Copy to mine functionality to copy this snippet to your own personal collection and easy manage your code snippets.

Codever is open source on Github ⭐🙏

Subscribe to our newsletter for more code resources and news

Adrian Matei (aka adixchen)

Adrian Matei (aka adixchen)
Life force expressing itself as a coding capable human being

routerLink with query params in Angular html template

routerLink with query params in Angular html template code snippet Continue reading