functions for date parsing.

Started by Jeff MacDonaldalmost 24 years ago4 messagesgeneral
Jump to latest
#1Jeff MacDonald
jeff@tsunamicreek.com

sample=> select age(now()::date,'1990-01-01'::date);
age
-------------------------------
12 years 5 mons 22 days 23:00

within postgres, how can i parse this to somethig like

12 years 5 months

Thanks..
Jeff.

#2Robert Treat
xzilla@users.sourceforge.net
In reply to: Jeff MacDonald (#1)
Re: functions for date parsing.

db=# select date_trunc('month',age(now()::date,'1990-01-01'::date));

date_trunc
-----------------
12 years 5 mons
(1 row)

Robert Treat

Show quoted text

On Mon, 2002-06-24 at 10:21, Jeff MacDonald wrote:

sample=> select age(now()::date,'1990-01-01'::date);
age
-------------------------------
12 years 5 mons 22 days 23:00

within postgres, how can i parse this to somethig like

12 years 5 months

Thanks..
Jeff.

#3Thomas Lockhart
lockhart@fourpalms.org
In reply to: Jeff MacDonald (#1)
Re: functions for date parsing.

sample=> select age(now()::date,'1990-01-01'::date);
-------------------------------
12 years 5 mons 22 days 23:00
within postgres, how can i parse this to somethig like
12 years 5 months

lockhart=# select date_trunc('month',
age(now()::date,'1990-01-01'::date));
-----------------
12 years 5 mons

to_char() will probably do what you need also.

- Thomas

#4Jeff MacDonald
jeff@tsunamicreek.com
In reply to: Robert Treat (#2)
Re: functions for date parsing.

Perfect ! Thanks.

Show quoted text

-----Original Message-----
From: Robert Treat [mailto:rtreat@webmd.net]
Sent: Monday, June 24, 2002 4:34 PM
To: Jeff MacDonald
Cc: Postgres List
Subject: Re: [GENERAL] functions for date parsing.

db=# select date_trunc('month',age(now()::date,'1990-01-01'::date));

date_trunc
-----------------
12 years 5 mons
(1 row)

Robert Treat

On Mon, 2002-06-24 at 10:21, Jeff MacDonald wrote:

sample=> select age(now()::date,'1990-01-01'::date);
age
-------------------------------
12 years 5 mons 22 days 23:00

within postgres, how can i parse this to somethig like

12 years 5 months

Thanks..
Jeff.