AGE
AGE(timestamp1, timestamp2)
Section titled “AGE(timestamp1, timestamp2)”- timestamp1: The timestamp to subtract from. When omitted, the current date at midnight is used.
- timestamp2: The timestamp to subtract.
Example
Section titled “Example”SELECT AGE(TIMESTAMP '2000-01-01');Output
Section titled “Output”age------------------21 years 10 monsExplanation
Section titled “Explanation”In the provided example, the AGE function in PostgreSQL is used to calculate the age between the current date and the specified date, ‘2000-01-01’. The result ‘21 years 10 mons’ shows the time difference in years and months.
age(timestamp, timestamp)
Section titled “age(timestamp, timestamp)”- timestamp: TIMESTAMP
- timestamp: TIMESTAMP
Example
Section titled “Example”SELECT age(TIMESTAMP '2001-04-10', TIMESTAMP '1992-09-20');