PostgreSQL Age Calculation from date type

前端 未结 2 771
执念已碎
执念已碎 2020-12-18 04:07

I have the following table:

CREATE TABLE public.employees
(
employee_id integer NOT NULL,
name text NOT NULL,
date_of_birth date,
address text,
email text,
C         


        
2条回答
  •  无人及你
    2020-12-18 05:04

    you can use age() function like this :

    SELECT name, EXTRACT(year FROM age(current_date,date_of_birth)) :: int as age FROM public.employees
    

提交回复
热议问题