w3resource logo


PostgreSQL bit length function

PostgreSQL AGE() function

Secondary Nav

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

Pictorial presentation of postgresql age function

Example 1 : PostgreSQL AGE() function

The example below finds the age between two dates specified in the argument.

SELECT age(timestamp '2015-01-15', timestamp '1972-12-28');

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.

SELECT age(timestamp '2007-10-07');

Output :

          age
-----------------------
 7 years 3 mons 7 days
(1 row)


Join our Question Answer community to learn and share your programming knowledge.

Help the community:

Python: Fizzbuzz

C++: Decimal to binary conversion

JavaScript: Need Help in JavaScript

Python: Help me with this program