Re: Trying to transform results of dow - Mailing list pgsql-novice

From Andrew McMillan
Subject Re: Trying to transform results of dow
Date
Msg-id 1034852611.1154.387.camel@kant.mcmillan.net.nz
Whole thread Raw
In response to Trying to transform results of dow  (Tan ga <gndtanga@mail.pt>)
List pgsql-novice
On Thu, 2002-10-17 at 22:31, Tan ga wrote:
> Hi I'm using extract(dow from table.field) and i would like to transform the
> result into it's corresponding day.Ex:0 into Sunday
>
> How can i do this?

You could look it up in a table, or you could hard-code it something
like this:

CASE extract(dow from table.field) WHEN 0 THEN 'Sunday' ELSE WHEN 1 THEN
'Monday' ELSE WHEN 2 THEN 'Tuesday'
...


But the simplest way is probably to do something like:

to_char( table.field, 'FMDay' )

:-)

Cheers,
                    Andrew.
> --
> Crie o seu email gratuito no mail.pt
> http://www.mail.pt
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
--
---------------------------------------------------------------------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St,  Wellington
WEB: http://catalyst.net.nz/         PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201     MOB: +64(21)635-694    OFFICE: +64(4)499-2267
           Survey for free with http://survey.net.nz/
---------------------------------------------------------------------


pgsql-novice by date:

Previous
From: Andrew McMillan
Date:
Subject: Re: char() or varchar() for frequently used column
Next
From: "paul butler"
Date:
Subject: Re: char() or varchar() for frequently used column