pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedAge in days
3+ messages / 3 participants
[nested] [flat]
* Age in days
@ 2005-09-09 16:04 Mark A. Strivens <strivens@bcm.edu>
0 siblings, 2 replies; 3+ messages in thread
From: Mark A. Strivens @ 2005-09-09 16:04 UTC (permalink / raw)
To: pgsql-sql
If you need to know the age to the nearest day on the present day
I think you can use something like:
select date_trunc('day',age(now(),dateofbirth)) from people
gives:
3 years 2 mons 12 days
My questions is, is there any way to convert that figure into an age
expressed as a number days only?
Many thanks
Mark
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Age in days
@ 2005-09-13 05:01 Gnanavel S <s.gnanavel@gmail.com>
parent: Mark A. Strivens <strivens@bcm.edu>
1 sibling, 0 replies; 3+ messages in thread
From: Gnanavel S @ 2005-09-13 05:01 UTC (permalink / raw)
To: strivens@bcm.edu; +Cc: pgsql-sql
This will give you the no of days.
select current_date - dateofbirth::date from people;
On 9/9/05, Mark A. Strivens <strivens@bcm.edu> wrote:
>
> If you need to know the age to the nearest day on the present day
> I think you can use something like:
>
> select date_trunc('day',age(now(),dateofbirth)) from people
>
> gives:
>
> 3 years 2 mons 12 days
>
> My questions is, is there any way to convert that figure into an age
> expressed as a number days only?
>
> Many thanks
>
> Mark
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>
--
with regards,
S.Gnanavel
Satyam Computer Services Ltd.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Age in days
@ 2005-09-13 05:12 Michael Glaesemann <grzm@myrealbox.com>
parent: Mark A. Strivens <strivens@bcm.edu>
1 sibling, 0 replies; 3+ messages in thread
From: Michael Glaesemann @ 2005-09-13 05:12 UTC (permalink / raw)
To: strivens@bcm.edu; +Cc: pgsql-sql
On Sep 10, 2005, at 1:04 AM, Mark A. Strivens wrote:
> select date_trunc('day',age(now(),dateofbirth)) from people
> My questions is, is there any way to convert that figure into an age
> expressed as a number days only?
Try
select current_date - dateofbirth from people;
Michael Glaesemann
grzm myrealbox com
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-09-13 05:12 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-09-09 16:04 Age in days Mark A. Strivens <strivens@bcm.edu>
2005-09-13 05:01 ` Gnanavel S <s.gnanavel@gmail.com>
2005-09-13 05:12 ` Michael Glaesemann <grzm@myrealbox.com>
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