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

Use test.each in jest to avoid repetitive tests

This blog post makes a case for using jest test.each wherever possible, by refactoring an existing test, thus making the code more concise and maintainable and reduce code duplication Continue reading