From: Gnanakumar <gnanam@zoniac.com>
To: 'Amitabh Kant' <amitabhkant@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Calculating relative time/distance from CURRENT_TIMESTAMP
Date: Thu, 4 Aug 2011 17:12:51 +0530
Message-ID: <001201cc529b$adc7c220$09574660$@com> (raw)
In-Reply-To: <CAPTAQBJ3YFkKVPm9LfQ=fRvmfBVuyAjT1nJ=mqodrsCv=+sOXA@mail.gmail.com>
References: <AcxSe8H2QUUOaGQtSI+h2lVo8iFPMQ==>
<009301cc527b$c48690b0$4d93b210$@com>
<CAPTAQBJ3YFkKVPm9LfQ=fRvmfBVuyAjT1nJ=mqodrsCv=+sOXA@mail.gmail.com>
Hi Amitabh,
Yes, I already took a glance of the Date/Time functions. But what I'm
expecting is something more meaningful/user-friendly value to be returned
than from the actual return value of these functions available here. I'm
just finding out whether this could be solved at query level itself.
For example, there is age(timestamp, timestamp) function. If I call like
this select age(current_timestamp, (current_timestamp - interval '1 day'))
it returns
"1 day". But what I'm expecting to be returned from the function is
something more meaningful/user-friendly to the end users. In this case, I
wanted it to return "yesterday", similarly today, 15 minutes ago, 1 week
ago, etc.
Regards,
Gnanam
From: Amitabh Kant [mailto:amitabhkant@gmail.com]
Sent: Thursday, August 04, 2011 4:34 PM
To: gnanam@zoniac.com
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Calculating relative time/distance from CURRENT_TIMESTAMP
Have you looked into the date time functions already ?
http://www.postgresql.org/docs/9.0/static/functions-datetime.html
Amitabh Kant
On Thu, Aug 4, 2011 at 1:24 PM, Gnanakumar <gnanam@zoniac.com> wrote:
Hi,
Is there any built-in function/add-on module available in PostgreSQL, that
converts a given "timestamp"/"timestamptz" value into its relative distance
from CURRENT_TIMESTAMP? For example, relative distance as today, yesterday,
5 minutes ago, 1 week ago, etc.
Regards,
Gnanam
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: gnanam@zoniac.com, amitabhkant@gmail.com
Subject: Re: Calculating relative time/distance from CURRENT_TIMESTAMP
In-Reply-To: <001201cc529b$adc7c220$09574660$@com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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