Re: Calculating relative time/distance from CURRENT_TIMESTAMP

Поиск
Список
Период
Сортировка
От Samuel Gendler
Тема Re: Calculating relative time/distance from CURRENT_TIMESTAMP
Дата
Msg-id CAEV0TzBu+vDhYp9R8Eeu1iCH2++VwABQcK+wVdSEExLgszZv5Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Calculating relative time/distance from CURRENT_TIMESTAMP  ("Gnanakumar" <gnanam@zoniac.com>)
Ответы Re: Calculating relative time/distance from CURRENT_TIMESTAMP  ("Gnanakumar" <gnanam@zoniac.com>)
Список pgsql-sql


On Thu, Aug 4, 2011 at 4:42 AM, Gnanakumar <gnanam@zoniac.com> wrote:

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.


If you really want a flexible function for doing this, I suspect you could replicate the functionality of jquery's 'timeago' module in a stored proc relatively easily. http://timeago.yarp.com/ It is MIT licensed, so you can copy the logic without restriction.  It makes reference to being derivative of a ruby project, so you could probably grab that code and convert it to ruby-pg very easily.
 

В списке pgsql-sql по дате отправления:

Предыдущее
От: Charlie
Дата:
Сообщение: Re: Calculating relative time/distance from CURRENT_TIMESTAMP
Следующее
От: "Gnanakumar"
Дата:
Сообщение: Re: Calculating relative time/distance from CURRENT_TIMESTAMP