Re: birthday calculation - Mailing list pgsql-general

From Pavel Stehule
Subject Re: birthday calculation
Date
Msg-id Pine.LNX.4.44.0307230927220.20834-100000@kix.fsv.cvut.cz
Whole thread Raw
In response to birthday calculation  (Ben <bench@silentmedia.com>)
Responses Re: birthday calculation  (Dennis Gearon <gearond@cvc.net>)
List pgsql-general
Hello

SELECT age(CURRENT_DATE, date '730715');
           age
--------------------------
 30 years 7 days 23:00:00
(1 row)

bye
ps


On 22 Jul 2003, Ben wrote:

> It must be late, because I cannot seem to figure this out. I've got a
> field which has a user's birthday - I want to figure out how old they
> are in terms of years.
>
> If I just do something like:
>
> select current_date - user.bday;
>
> I get their age in days, which doesn't let me take leap years into
> account. Is there a simple magic date_diff function that I'm missing? Or
> lacking that some other way to get postgres to do the date calculations?
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>       joining column's datatypes do not match
>


pgsql-general by date:

Previous
From: Jean-Christian Imbeault
Date:
Subject: Re: 0/1 vs true/false
Next
From: Ron Johnson
Date:
Subject: Re: String Comparison / Embedded Spaces