Skip site navigation (1) Skip section navigation (2)

Re: Trying to transform results of dow

From: Andrew McMillan <andrew(at)catalyst(dot)net(dot)nz>
To: Tan ga <gndtanga(at)mail(dot)pt>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Trying to transform results of dow
Date: 2002-10-17 11:03:31
Message-ID: 1034852611.1154.387.camel@kant.mcmillan.net.nz (view raw or flat)
Thread:
Lists: 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/ 
---------------------------------------------------------------------


In response to

pgsql-novice by date

Next:From: paul butlerDate: 2002-10-17 12:28:55
Subject: Re: char() or varchar() for frequently used column
Previous:From: Andrew McMillanDate: 2002-10-17 10:58:10
Subject: Re: char() or varchar() for frequently used column

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group