pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Najm Hashmi <najm@mondo-live.com>
To: Hans-Jürgen Schönig <hs@cybertec.at>
Cc: pgsql-sql@postgresql.org
Subject: Re: Calculating the age of a person
Date: Tue, 22 May 2001 10:20:56 -0400
Message-ID: <3B0A75C8.2020906@mondo-live.com> (raw)
References: <3B052603.ADBEB496@cybertec.at>

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@postgresql.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




view thread (4+ messages)

Message-ID: <3B0A75C8.2020906@mondo-live.com>
Permalink:  ../3B0A75C8.2020906@mondo-live.com/
Also on:    postgresql.org/message-id/3B0A75C8.2020906@mondo-live.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: najm@mondo-live.com, hs@cybertec.at
  Subject: Re: Calculating the age of a person
  In-Reply-To: <3B0A75C8.2020906@mondo-live.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox