pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aaron Bono <postgresql@aranya.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Mike C <smith.not.western@gmail.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: SELECT and DATE Function question
Date: Mon, 11 Sep 2006 10:03:34 -0500
Message-ID: <bf05e51c0609110803k2e9679d2ma200b00fa10f4651@mail.gmail.com> (raw)
In-Reply-To: <22488.1157983704@sss.pgh.pa.us>
References: <bd0eabd0609102153h71fd59ffv6d0ca8a78c27fd9c@mail.gmail.com>
	<bf05e51c0609102227u10e4e4c6j7fcdb06690bb9f5b@mail.gmail.com>
	<22488.1157983704@sss.pgh.pa.us>

On 9/11/06, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> "Aaron Bono" <postgresql@aranya.com> writes:
> > Use:
>
> > select start_date + (cast(number_of_days as text) || ' days')::interval
> from
> > blah
>
> This is a pretty awful way to do it, much better is
>
>         select start_date + number_of_days * '1 day'::interval ...
>
> which reduces to basically one multiplication instead of conversion to
> text, text string append, parse interval string value (relying on a
> couple of undocumented cast abilities).



I knew there was a better way but I forgot what it was and couldn't find it
in the documentation.

Could the documentation be updated with this example?  This question appears
every month or so and I know it is very useful to many people.

Thanks!

==================================================================
   Aaron Bono
   Aranya Software Technologies, Inc.
   http://www.aranya.com
   http://codeelixir.com
==================================================================

view thread (6+ messages)

Message-ID: <bf05e51c0609110803k2e9679d2ma200b00fa10f4651@mail.gmail.com>
Permalink:  ../bf05e51c0609110803k2e9679d2ma200b00fa10f4651@mail.gmail.com/
Also on:    postgresql.org/message-id/bf05e51c0609110803k2e9679d2ma200b00fa10f4651@mail.gmail.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: postgresql@aranya.com, tgl@sss.pgh.pa.us, smith.not.western@gmail.com
  Subject: Re: SELECT and DATE Function question
  In-Reply-To: <bf05e51c0609110803k2e9679d2ma200b00fa10f4651@mail.gmail.com>
  References: <bd0eabd0609102153h71fd59ffv6d0ca8a78c27fd9c@mail.gmail.com> <bf05e51c0609102227u10e4e4c6j7fcdb06690bb9f5b@mail.gmail.com> <22488.1157983704@sss.pgh.pa.us> <bf05e51c0609110803k2e9679d2ma200b00fa10f4651@mail.gmail.com>

* 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