From: Bret Hughes <bhughes@elevating.com>
To: postgresql sql list <pgsql-sql@postgresql.org>
Subject: Re: definative way to place secs from epoc into timestamp
Date: 03 Mar 2005 01:21:38 -0600
Message-ID: <1109834498.27905.142.camel@bretsony> (raw)
In-Reply-To: <17735.1109831102@sss.pgh.pa.us>
References: <1109780719.28180.86.camel@bretsony>
<13089.1109793126@sss.pgh.pa.us>
<1109794066.27857.100.camel@bretsony>
<13466.1109795186@sss.pgh.pa.us>
<1109828560.27905.137.camel@bretsony>
<17735.1109831102@sss.pgh.pa.us>
On Thu, 2005-03-03 at 00:25, Tom Lane wrote:
> Bret Hughes <bhughes@elevating.com> writes:
> > create function int2ts(integer) returns timestamp as '
> > SELECT ( TIMESTAMP WITH TIME ZONE \'epoch\' + $1 * INTERVAL \'1
> > second\')::timestamp without time zone;
> > ' language sql;
>
> > create function ts2int(timestamp without time zone) returns int as '
> > select extract( \'epoch\' from $1)::integer;
> > ' language sql;
>
> Looks good as far as it goes. Two thoughts:
>
> * both functions should probably be marked STRICT STABLE
> (not IMMUTABLE, because they depend on the local timezone setting).
>
> * have you considered allowing the numeric values to be float8 instead
> of integer? There doesn't seem any reason to disallow sub-second
> precision.
>
well no I had not considered it but am now :)
I need to read some more as to the STRICT STABLE stuff, thanks for the
tips.
Bret
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: bhughes@elevating.com
Subject: Re: definative way to place secs from epoc into timestamp
In-Reply-To: <1109834498.27905.142.camel@bretsony>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox