how to add seconds to a TimestampTz

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: how to add seconds to a TimestampTz
Date: 2007-03-14 22:45:55
Message-ID: 20070314224555.GE25817@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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)

but it doesn't seem clean, and the comments in the functions more or
less say that their use is discouraged.

I saw about doing it via the interval input/output but that's an awful
lot of work ...

Is this the first time this is going to be done in the backend?

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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Trent Shipley 2007-03-15 01:12:22 Re: My honours project - databases using dynamically attached entity-properties
Previous Message Simon Riggs 2007-03-14 21:41:49 Re: hash join hashtable size and work_mem