Re: epoch to timestamp

From: Randall Lucas <rlucas(at)tercent(dot)net>
To: Lucas Lain <lainl(at)aconectarse(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: epoch to timestamp
Date: 2003-05-12 15:22:59
Message-ID: 9D469787-848D-11D7-B164-000A957653D6@tercent.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

Hi Lucas,

Just nest or chain your casts as appropriate.

example=> select cast(cast(105471234 as abstime) as timestamp);
timestamp
---------------------
1973-05-05 13:33:54
(1 row)

Time: 1.81 ms
example=> select 105471234::abstime::timestamp;
timestamp
---------------------
1973-05-05 13:33:54
(1 row)

Time: 1.97 ms

Best,

Randall

On Monday, May 12, 2003, at 11:05 AM, Lucas Lain wrote:

> i really dont know how to do it ... i'm a newbie
> it is something like this?
>
> select cast(105471234 AS abstime) ...
>
> and then?
>
>
>
> On Fri, 9 May 2003 16:36:48 -0500
> Bruno Wolff III <bruno(at)wolff(dot)to> wrote:
>
>> On Fri, May 09, 2003 at 18:05:45 -0300,
>> Lucas Lain <lainl(at)aconectarse(dot)com> wrote:
>>>
>>> can anyone tell me how to convert an epoch date to timestamp format??
>>
>> If the epoch date is an integer with seconds since the unix epoch,
>> you can cast it to abstime and then to timestamp.
>>
>
>
> --
> Lucas Lain
> lainl(at)aconectarse(dot)com
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to
> majordomo(at)postgresql(dot)org)
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Larry Rosenman 2003-05-12 15:26:30 Re: epoch to timestamp
Previous Message Lucas Lain 2003-05-12 15:05:44 Re: epoch to timestamp

Browse pgsql-sql by date

  From Date Subject
Next Message Larry Rosenman 2003-05-12 15:26:30 Re: epoch to timestamp
Previous Message Lucas Lain 2003-05-12 15:05:44 Re: epoch to timestamp