On Thu, Aug 4, 2011 at 4:42 AM, Gnanakumar <gna...@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.