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

Поиск
Список
Период
Сортировка
От Christopher Kings-Lynne
Тема Re: How do I get the current time in seconds in the unix epoch?
Дата
Msg-id ECEHIKNFIMMECLEBJFIGMEDGCCAA.chriskl@familyhealth.com.au
обсуждение исходный текст
Ответ на How do I get the current time in seconds in the unix epoch?  (Bill Studenmund <wrstuden@netbsd.org>)
Ответы Re: How do I get the current time in seconds in the unix  (Bill Studenmund <wrstuden@netbsd.org>)
Список 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

Hmmm.  I don't know why date_part isn't working, but I now only use the
EXTRACT syntax for maximum SQL compatibility.  ie. Do this instead:

v_seed := EXTRACT (EPOCH FROM CURRENT_TIMESTAMP);

Cheers,

Chris



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

Предыдущее
От: Lincoln Yeoh
Дата:
Сообщение: Re: Pre-forking backend
Следующее
От: Barry Lind
Дата:
Сообщение: Re: Deadlock? idle in transaction