I tried it all of these ways:
select DISTINCT ON (f.id) f.id, f.artist_name, f.track_title, f.album_title, f.label, f.isrc_number
from cc_files as f, cc_playout_history as h, cc_timestamp as t
where f.id = h.file_id AND h.starts = t.id AND (t.timestamp > ‘2018-03-04 00:00:00’ AND t.timestamp < ‘2018-03-17 23:59:59’);
SELECT DISTINCT ON (f.id) f.id, f.artist_name, f.track_title, f.album_title, f.label, f.isrc_number
FROM cc_files AS f, cc_playout_history AS h, cc_timestamp AS t
WHERE f.id = h.file_id AND h.starts = t.id AND (t.timestamp >= to_timestamp(‘2018-03-04 00:00:00’, ‘YYYY-MM-DD HH:MM:SS’)
AND t.timestamp < to_timestamp(‘2018-03-17 23:59:59’, ‘YYYY-MM-DD HH:MM:SS’));
SELECT DISTINCT ON (f.id) f.id, f.artist_name, f.track_title, f.album_title, f.label, f.isrc_number
FROM cc_files AS f, cc_playout_history AS h, cc_timestamp AS t
WHERE f.id = h.file_id AND h.starts = t.id AND (t.timestamp >= timestamp ‘2018-03-04 00:00:00’ AND t.timestamp < timestamp ‘2018-03-17 23:59:59’);
SELECT DISTINCT ON (f.id) f.id, f.artist_name, f.track_title, f.album_title, f.label, f.isrc_number
FROM cc_files AS f, cc_playout_history AS h, cc_timestamp AS t
WHERE f.id = h.file_id AND h.starts = t.id AND (date_part(t.timestamp) >= 1520121600 AND date_part(t.timestamp) < 1521331200);
SELECT DISTINCT ON (f.id) f.id, f.artist_name, f.track_title, f.album_title, f.label, f.isrc_number
FROM cc_files AS f, cc_playout_history AS h, cc_timestamp AS t
WHERE f.id = h.file_id AND h.starts = t.id AND (date_trunc(t.timestamp) >= ‘2018-03-04’ AND date_trunc(t.timestamp) < ‘2018-03-18’);
And I get the same error each time: operator does not exist:timestamp without time zone = integer.
I thought, maybe I need to convert my beginning and end dates to unix timestamps to do integer comparison, but that didn’t work either.