Reputation: 3797
I would like to select records that was created exactly N days ago.
I have something like this:
WHERE created_at = NOW() - (N || ' days')::interval
But this doesn't work, any ideas?
Upvotes: 0
Views: 61
Reputation: 18814
You should use the date part I believe, something like:
select created_at::date = (current_date - (N || ' days')::interval)::date;
This will take the date part of your timestamp:
select '2016-06-28 07:51:19.583104'::date
Will give you:
2016-06-28
Upvotes: 1