From: | Bret Hughes <bhughes(at)elevating(dot)com> |
---|---|
To: | postgresql sql list <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: definative way to place secs from epoc into timestamp |
Date: | 2005-03-03 07:21:38 |
Message-ID: | 1109834498.27905.142.camel@bretsony |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Thu, 2005-03-03 at 00:25, Tom Lane wrote:
> Bret Hughes <bhughes(at)elevating(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Bret Hughes | 2005-03-03 07:27:25 | Re: definative way to place secs from epoc into timestamp |
Previous Message | Smit | 2005-03-03 07:19:49 | how to monitor the archiving process? |