From: | Oliver Elphick <olly(at)lfix(dot)co(dot)uk> |
---|---|
To: | Matthew Lock <lock_matthew(at)hotmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Convert number of month to name of month |
Date: | 2002-08-02 17:59:43 |
Message-ID: | 1028311184.25315.138.camel@linda |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, 2002-07-30 at 07:02, Matthew Lock wrote:
> How do I build a query that takes a field containing the number of the
> month (1, 2, ..12) and displays it as the name of the month (Jan, Feb,
> ..Dec)?
>
> For example:
> 1 as Jan
> 2 as Feb
> etc.
In plain SQL, use CASE:
SELECT CASE
WHEN monthno = 1 THEN 'January'
WHEN monthno = 2 THEN 'February'
...
END AS month
FROM ...
You could also write a function in PL/PGSQL...
--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight, UK
http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"All scripture is given by inspiration of God, and is
profitable for doctrine, for reproof, for correction,
for instruction in righteousness;"
II Timothy 3:16
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Sullivan | 2002-08-02 18:02:49 | Re: MySQL or Postgres ? |
Previous Message | Hervé Piedvache | 2002-08-02 17:55:43 | Re: Regular expressions or LIKE ? HELP needed ! |