Re: how to add seconds to a TimestampTz

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: how to add seconds to a TimestampTz
Дата
Msg-id 20070320132938.GR24234@alvh.no-ip.org
обсуждение исходный текст
Ответ на how to add seconds to a TimestampTz  (Alvaro Herrera <alvherre@commandprompt.com>)
Список pgsql-hackers
Alvaro Herrera wrote:
> Is there a better way than going to time_t and back?  I am currently
> using this:
> 
>     db->next_worker =
>         time_t_to_timestamptz(timestamptz_to_time_t(current_time) +
>                       autovacuum_naptime);
> 
> (db->next_worker is a TimestampTz, as is current_time.
> autovacuum_naptime is integer for a number of seconds)

For the archives, I just discovered on timestamp.h this macro to help:
avdb->ad_next_worker =    TimestampTzPlusMilliseconds(now, naptime_secs * 1000);

This is a lot simpler and faster ...

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


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

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: Buildfarm feature request: some way to track/classify failures
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: modifying the tbale function