Re: any built-in function to get time in seconds?

From: Scott Bailey <artacus(at)comcast(dot)net>
To: zhong ming wu <mr(dot)z(dot)m(dot)wu(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: any built-in function to get time in seconds?
Date: 2010-04-03 19:08:30
Message-ID: 4BB7922E.3020808@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

zhong ming wu wrote:
> I have been using this one liner c function that I call my_now() to
> get the number of seconds since some fixed point in the past. I find
> it more convenient than built-in now()
> and if I want abstime I do abstime(my_now()). Thing is everytime I
> do a major version upgrade I had to recompile this and it's a pain in
> the neck. I feel there must be something
> built-in with pg to get the same thing since I can get abstime from it
> like that.
>
Well you haven't specified which fixed point in the past. But if you
want to get the number of seconds since the unix epoch use:

extract(epoch from current_timestamp)

Scott

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2010-04-04 01:32:25 Re: Connection Pooling
Previous Message Scott Bailey 2010-04-03 19:02:03 Re: count function alternative in postgres