Re: Cast timestamptz to/from integer?

From: Bartosz Dmytrak <bdmytrak(at)gmail(dot)com>
To: Chris Angelico <rosuav(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Cast timestamptz to/from integer?
Date: 2012-04-03 09:26:11
Message-ID: CAD8_UcZXO16KHrL8LMyphwzsXCb31L3=dhjVHKNb_+QKvr-1aw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

There is a build in function which encapsulates that statement:

SELECT to_timestamp (982384720);

EXPLAIN ANALYZE shows:
Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.002..0.003 rows=1
loops=1)

so this looks cheap

Regards,
Bartek

2012/4/3 Chris Angelico <rosuav(at)gmail(dot)com>

> On Tue, Apr 3, 2012 at 7:11 PM, Bartosz Dmytrak <bdmytrak(at)gmail(dot)com>
> wrote:
> > I think You can use epoch
> > there is an
> > example:
> http://www.postgresql.org/docs/9.1/static/functions-datetime.html
> >
> >
> > SELECT TIMESTAMP WITH TIME ZONE 'epoch' + 982384720.12 * INTERVAL '1
> > second';
>
> Yep, but when you do that a lot, your statement gets extremely long. I
> can create a function that'll hide the mess away, but what I'm hoping
> to do is simply cast:
>
> SELECT 982384720::timestamptz;
>
> ChrisA
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ronan Dunklau 2012-04-03 09:48:59 Re: User-defined Aggregate function and performance.
Previous Message Chris Angelico 2012-04-03 09:13:52 Re: Cast timestamptz to/from integer?