Calculate age by birthdate with SQL
Simple snippet for calculating age by birthdate with SQL
SELECT
id,
firstname,
lastname,
date_of_birth,
EXTRACT(YEAR FROM age(users.date_of_birth::DATE)) AS age
FROM users;
/*
id |firstname |lastname |date_of_birth |age
-----------------------------------------------------
24 |"Max" |"Mustermann" |"1987-08-12" |25
51 |"John" |"Doe" |"1985-02-03" |28
*/
Url: http://sklueh.de/2013/03/alter-uber-geburtsdatum-mit-postgresql-ermitteln/
Language: SQL | User: sklueh | Created: Sep 24, 2013 | Tags: sql birthdate