pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bret Hughes <bhughes@elevating.com>
Cc: postgresql sql list <pgsql-sql@postgresql.org>
Subject: Re: definative way to place secs from epoc into timestamp
Date: Thu, 03 Mar 2005 01:25:02 -0500
Message-ID: <17735.1109831102@sss.pgh.pa.us> (raw)
In-Reply-To: <1109828560.27905.137.camel@bretsony>
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>

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.

			regards, tom lane



view thread (19+ messages)  latest in thread

Message-ID: <17735.1109831102@sss.pgh.pa.us>
Permalink:  ../17735.1109831102@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/17735.1109831102@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, bhughes@elevating.com
  Subject: Re: definative way to place secs from epoc into timestamp
  In-Reply-To: <17735.1109831102@sss.pgh.pa.us>

* 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