PostgreSQL
 sql >> Database >  >> RDS >> PostgreSQL

Come sottrarre/aggiungere minuti da un timestamp in postgreSQL

Date, orari e timestamp in PostgreSQL possono essere aggiunti/sottratti un valore INTERVAL:

SELECT now()::time - INTERVAL '10 min'

Se il tuo campo timestamp è varchar, puoi prima trasmetterlo al tipo di dati timestamp e quindi sottrarre l'intervallo:

 ( (left(precence_records.created::text, 11) || ' ') ||
   (contacts.entry_time::time + INTERVAL '10min')::text )::timestamp <
 precence_records.created::timestamp