I am trying to query for accounts that have been pending approval for exactly two (2) days. The "created_at" column is timestamp without time zone. The issue I'm facing is I do not know how to filter the "created_at" column to be exactly two days ago. This is what I have so far:
SELECT *
FROM kyc_document_check
WHRE status = 'pending'
AND created_at =
And I don't know what to put after created_at =
to make it exactly two days ago.
I'm using PostgreSQL database with pgAdmin-4
CodePudding user response:
If created_at is a date
, then use:
where created_at = current_date - 2;
If it is a timestamp
it's better to use a range condition because of the time part:
where created_at >= current_date - 2
and created_at < current_date - 1;
CodePudding user response:
Try this:
SELECT *
FROM kyc_document_check
WHERE status = 'pending' AND = age(created_at, current_timestamp()) = '2 days'