Обсуждение: changing 'mons' in interval?

Поиск
Список
Период
Сортировка

changing 'mons' in interval?

От
Klint Gore
Дата:
Is there a way to change mons in interval::text to the full word months
without resorting to "replace(aninterval::text,'mon','Month')"?  If it
can handle locales as well that would be good (but I could live without
it).

klint.

+---------------------------------------+-----------------+
: Klint Gore                            : "Non rhyming    :
: EMail   : kg@kgb.une.edu.au           :  slang - the    :
: Snail   : A.B.R.I.                    :  possibilities  :
: Mail      University of New England   :  are useless"   :
:           Armidale NSW 2351 Australia :     L.J.J.      :
: Fax     : +61 2 6772 5376             :                 :
+---------------------------------------+-----------------+

Re: changing 'mons' in interval?

От
Martijn van Oosterhout
Дата:
On Mon, Jun 04, 2007 at 06:51:37PM +1000, Klint Gore wrote:
> Is there a way to change mons in interval::text to the full word months
> without resorting to "replace(aninterval::text,'mon','Month')"?  If it
> can handle locales as well that would be good (but I could live without
> it).

Have you considered using to_char to get the output in the exact format
you want?

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Вложения

Re: changing 'mons' in interval?

От
Klint Gore
Дата:
On Mon, 4 Jun 2007 11:43:08 +0200, Martijn van Oosterhout <kleptog@svana.org> wrote:
> On Mon, Jun 04, 2007 at 06:51:37PM +1000, Klint Gore wrote:
> > Is there a way to change mons in interval::text to the full word months
> > without resorting to "replace(aninterval::text,'mon','Month')"?  If it
> > can handle locales as well that would be good (but I could live without
> > it).
>
> Have you considered using to_char to get the output in the exact format
> you want?

Yes.  It turned out to be a fairly complex statement with case's of
extracts to handle plurals and negatives.  That's what lead me to asking.

besides
http://www.postgresql.org/docs/7.4/interactive/functions-formatting.html
"Warning: to_char(interval, text) is deprecated and should not be used
in newly-written code. It will be removed in the next version."

http://www.postgresql.org/docs/8.0/interactive/functions-formatting.html
"Warning: to_char(interval, text) is deprecated and should not be used
in newly-written code. It will be removed in the next version."

And 8.1/8.2 seem to have been revived that warning but still has
to_char(interval,text)

klint.

+---------------------------------------+-----------------+
: Klint Gore                            : "Non rhyming    :
: EMail   : kg@kgb.une.edu.au           :  slang - the    :
: Snail   : A.B.R.I.                    :  possibilities  :
: Mail      University of New England   :  are useless"   :
:           Armidale NSW 2351 Australia :     L.J.J.      :
: Fax     : +61 2 6772 5376             :                 :
+---------------------------------------+-----------------+