Thread: output format for dates

output format for dates

From
am@fx.ro
Date:
hello all!

I need a piece of advice regarding date styles. I've tried all
the datestyles, but none of them seems to look the way i want.

I would like to use the following format for dates:
DD-MON-YYYY or DD-MON-YY, where MON is one of : JAN,FEB,..,DEC.
(for example 20-APR-2002) for both input and output.

I've noticed that Postgres accepts dates in this format, so the
input part is ok. But for output, it uses the 'european' style.

So, here comes my question:  is it possible to create a new
custom datestyle and set it as default ?


Thanks in advance,
Adrian Maier (am@fx.ro)

Re: output format for dates

From
Alvaro Herrera
Date:
am@fx.ro dijo:

Hi,

> I would like to use the following format for dates:
> DD-MON-YYYY or DD-MON-YY, where MON is one of : JAN,FEB,..,DEC.
> (for example 20-APR-2002) for both input and output.

You can use to_char(),

regression=# select (to_char('20-04-2002'::date, 'dd-MON-yyyy'));
   to_char
-------------
 20-APR-2002
(1 row)

regression=#

--
Alvaro Herrera (<alvherre[a]atentus.com>)
"Y eso te lo doy firmado con mis lagrimas" (Fiebre del loco)