From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: how to add seconds to a TimestampTz |
Date: | 2007-03-20 13:29:38 |
Message-ID: | 20070320132938.GR24234@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2007-03-20 13:35:11 | Re: modifying the tbale function |
Previous Message | Andrew Dunstan | 2007-03-20 13:24:26 | Re: Buildfarm feature request: some way to track/classify failures |