superboy143 (sent by Nabble.com) wrote:
Hello,
How can I write an sql query in postgresql so that I can insert a date into
a table in the format DD-MM-YYYY, and when I select the date from the table
I should get the date in the same format.
See postgresql.conf documentation
(http://www.postgresql.org/docs/8.1/interactive/runtime-config-client.html#RUNTIME-CONFIG-CLIENT-FORMAT):
17. Server Configuration
17.10.2. Locale and Formatting
DateStyle = 'German, dmy'
- output format specification: German
- input/output specification for year/month/day ordering: DMY
postgres=# SHOW datestyle;
DateStyle
-------------
German, DMY
(1 row)
postgres=# SELECT CURRENT_DATE;
date
------------
10.02.2006
(1 row)
postgres=# SELECT to_char('09/03/2005'::date,'dd/mon/yyyy');
to_char
-------------
09/mar/2005
(1 row)
[]s
Osvaldo
_______________________________________________________
Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador agora!
http://br.acesso.yahoo.com
---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match