Re: Convert "epoch" to timestamp

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Convert "epoch" to timestamp
Date: 2002-04-23 14:54:44
Message-ID: 20020423075313.W13153-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Tue, 23 Apr 2002, Jeff Eckermann wrote:

> jeff=# select version();
> version
>
> -------------------------------------------------------------------
> PostgreSQL 7.2 on i386-portbld-freebsd4.5, compiled
> by GCC 2.95.3
> (1 row)
>
> I need to convert the "epoch" (i.e. number of seconds)
> timestamp to a PostgreSQL timestamp.
>
> The extract/date_part functions do it easily the other
> way, but I have had some difficulty in doing what I
> need.
>
> According to posts in the archives, the following used
> to work:
>
> jeff=# select extract (epoch from
> current_timestamp(0));
> date_part
> ------------
> 1019571752
> (1 row)
>
> jeff=# select timestamp(1019571752);
> ERROR: TIMESTAMP(1019571752) WITH TIME ZONE precision
> must be between 0 and 13

You'd need to double quote that timestamp to differentiate
the function from the data type: "timestamp"(1019571752)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Lockhart 2002-04-23 15:04:20 Re: Convert "epoch" to timestamp
Previous Message Alejandro Fernandez 2002-04-23 14:51:40 Connections per second?