select dates between two unix timestamps

postgresql, timestamp, unix-timestamp

Solution

SELECT *
FROM users
WHERE user_date BETWEEN
  EXTRACT(EPOCH FROM date '2012-10-21') AND
  EXTRACT(EPOCH FROM date '2012-10-24' + interval '1 day');

If you don't want the end date to be included, remove the bit adding a day to that.

Problem

I have the table users. Columns: - user_id - integer - user_date - integer(unix timestamp) Some of rows have user_date and some have NULL. I need to find all user_id's which user_date includes period between '2012-10-21' and '2012-10-24'

Original source