From: | Najm Hashmi <najm(at)mondo-live(dot)com> |
---|---|
To: | Hans-Jürgen Schönig <hs(at)cybertec(dot)at> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Calculating the age of a person |
Date: | 2001-05-22 14:20:56 |
Message-ID: | 3B0A75C8.2020906@mondo-live.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hans-Jürgen Schönig wrote:
> I have a table containing the birthdays of various persons. The target
> is to compute the age of a persons.
>
> persons=# SELECT age(birth), * FROM persons LIMIT 1;
> age | id | name | birth | gender |
> income
> -------------------------------+----+--------+------------+--------+--------
>
> 31 years 4 mons 16 days 23:00 | 1 | Albert | 1970-01-01 | m |
> 35000
> (1 row)
>
> When I use age() I don't get full years. Is there an easy way to round
> ::reltime off or up without writing a function. Is there any possibility
> to use plain SQL only?
>
> Hans
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
Hey Hans try usting date_part function.... select
date_part('year',birth)....
Regards
--
Najm Hashmi
Tel:514-271-9791
www.mondo-live.com
www.flipr.com
From | Date | Subject | |
---|---|---|---|
Next Message | Ross J. Reedstrom | 2001-05-22 14:53:55 | Re: RULES |
Previous Message | waheed rahman | 2001-05-22 13:19:13 | Please help me.... |