How do I get the current time in seconds in the unix epoch?

From: Bill Studenmund <wrstuden(at)netbsd(dot)org>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: How do I get the current time in seconds in the unix epoch?
Date: 2001-10-11 16:17:45
Message-ID: Pine.NEB.4.33.0110110910290.15927-100000@vespasia.home-net.internetconnect.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I have a function in PL/pgSQL which needs the current time in seconds
expressed as an int4. In 7.1 I was able to get this (I thought) with
date_part(''epoch'', timestamp ''now'') . That doesn't seem to work for me
in last week's -current.

Here's the PLpgSQL:

v_seed := date_part(''epoch'', timestamp ''now'');

And here's the output:

NOTICE: Error occurred while executing PL/pgSQL function
NOTICE: line 4 at assignment
ERROR: Timestamp with time zone units 'epoch' not recognized

What's the best way to do this?

Take care,

Bill

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-10-11 16:24:42 Re: Suitable Driver ?
Previous Message Tom Lane 2001-10-11 16:15:16 Re: pg_dump oid problems