PostgreSQL AGE() function
AGE() function
The age() function subtract arguments, producing a "symbolic" result that uses years and months.
Syntax:
age(timestamp, timestamp) or age(timestamp)
Return Type: interval
PostgreSQL Version: 9.3
Pictorial Presentation of PostgreSQL AGE() function

Example 1: PostgreSQL AGE() function
The example below finds the age between two dates specified in the argument.
Code
SELECT age(timestamp '2015-01-15', timestamp '1972-12-28');
Sample Output:
age ------------------ 42 years 18 days (1 row)
Example 2:
The example below finds the age between current date and the date as specified in the argument.
Code
SELECT age(timestamp '2007-10-07');
Sample Output:
age ----------------------- 7 years 3 mons 7 days (1 row)
Previous: Date and Time Operators
Next: CLOCK_TIMESTAMP function
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join