Determining period between 2 dates

From: Thom Brown <thom(at)linux(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Determining period between 2 dates
Date: 2011-02-16 15:47:00
Message-ID: AANLkTimHgQfzZPYY2Wq66VaOLxp=G5Cit4_uKgQBigiA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

I'm wondering what people think of introducing some kind of function
to extract the number of units between 2 dates? At the moment there's
no way to do this. Take the following example:

Event 1 is '1985-10-26 01:22:00'
Event 2 is now.

How many minutes between these 2 events? What I don't want is how
many years, months, days and hours there are between them.

This could potentially involve implementing age(timestamp, timestamp,
interval), like:

postgres=# SELECT age(current_date, '1985-10-26 01:22:00'::timestamp,
'1 second') as age_in_seconds;
age_in_seconds
----------------
798733367
(1 row)

Is this easily done?

Thanks

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-02-16 15:52:13 Re: Determining period between 2 dates
Previous Message Heikki Linnakangas 2011-02-16 15:40:41 Re: Sync Rep for 2011CF1