Interval Rounding

From: Mike Ginsburg <mginsburg(at)collaborativefusion(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Interval Rounding
Date: 2007-06-01 17:11:59
Message-ID: 4660535F.9020205@collaborativefusion.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,
I have a table that contains a user's response and a timestamp at
which it was last updated. I want to query for this response, and the
amount of time that has elapsed since, rounded to the nearest unit (e.g.
minutes, days, months, etc). I am using:

SELECT NOW() - change_time
FROM ...

to get the interval, and am attempting to use either EXTRACT() or
DATE_PART() to get the appropriate value, but the interval doesn't
contain any unit higher than days.

Any thoughts on how I could accomplish this? Thanks in advance

Mike Ginsburg
Collaborative Fusion, Inc.
mginsburg(at)collaborativefusion(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tyler Durden 2007-06-01 17:17:12 Re: Seq Scan
Previous Message Simon Riggs 2007-06-01 17:07:00 Re: warm standby server stops doingcheckpointsafterawhile