Date subtraction in postgres

postgresql

Solution

Multiply the interval by `interval '1 minute'`

SELECT *
FROM A, B 
WHERE 
   A.entity_type_id = B.entity_type_id  
   AND A.status = 'PENDING'  
   AND A.request_time < NOW() - B.retry_interval * INTERVAL '1 minute'
   AND A.retry_count >= B.retry_allowed_count

Problem

I want to subtract minute from `NOW()` and the value of "how many minutes" I am reading from another table: ``` SELECT * FROM A, B WHERE A.entity_type_id = B.entity_type_id AND A.status = 'PENDING' AND A.request_time < (NOW() - INTERVAL B.retry_interval MINUTE) AND A.retry_count >= B.retry_allowed_count ``` Here the problem is `B.retry_interval` is fetched from another table, while normally the queries like these are `A.request_time < (NOW() - INTERVAL '10 MINUTE')` How do I achieve this?

Original source