↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Functions / Date/Time Functions And Operators

Subtract arguments, producing a “symbolic” result that uses years and months, rather than just days

Reading PG 18current·documented in 27 of 27 versions, 7.1 to 20

Signatures & examples

age ( timestamp, timestamp ) → interval
Subtract arguments, producing a “symbolic” result that uses years and months, rather than just days
age(timestamp '2001-04-10', timestamp '1957-06-13') → 43 years 9 mons 27 days
age ( timestamp ) → interval
Subtract argument from current_date (at midnight)
age(timestamp '1957-06-13') → 62 years 6 mons 10 days
age ( xid ) → integer
Returns the number of transactions between the supplied transaction id and the current transaction counter.
Version history 4
  1. 12 → 13 changed
  2. 9.6 → 10 changed
  3. 9.3 → 9.4 changed
  4. 7.4 → 8.0 changed

Definition snapshot: b7bd9cda · English manual source