Answer the question
In order to leave comments, you need to log in
Why does date comparison not work in PostgreSQL?
There is a table. It is necessary to select records from the table earlier than obj.added - incoming parameter
create table user_recording(
"id" serial primary key,
"userId" serial REFERENCES user (id),
"recordingId" serial REFERENCES recording (id) on delete cascade,
"added" timestamp,
unique ("userId", "recordingId")
);
SELECT *
FROM user_recording
WHERE user_recording."userId" = ${obj.userId} AND user_recording.added::timestamp <= ${obj.added}
ORDER BY user_recording.added DESC
LIMIT ${obj.limit};`
error: operator does not exist: timestamp without time zone <= bigint
Answer the question
In order to leave comments, you need to log in
Compare values of different types - timestamp with a number. Moreover, the number you have is not seconds at all, but milliseconds.
Try replacing user_recording.added::timestamp
with extract('epoch' from user_recording.added) * 1000
.
Or replace ${obj.added}
with to_timestamp(${obj.added / 1000})
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question