date
date
От:
"superboy143 (sent by Nabble.com)" <lists@nabble.com>
Дата:
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. -- View this message in context: http://www.nabble.com/date-t1097526.html#a2865031 Sent from the PostgreSQL - sql forum at Nabble.com.
Re: date
От:
"A. Kretschmer" <andreas.kretschmer@schollglas.com>
Дата:
am 09.02.2006, um 22:18:09 -0800 mailte superboy143 (sent by Nabble.com) folgendes: > > 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. You can't define the format in the db, but you can define the output-format with to_char(date, 'DD-MM-YYYY'); HTH, Andreas -- Andreas Kretschmer (Kontakt: siehe Header) Heynitz: 035242/47215, D1: 0160/7141639 GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net=== Schollglas Unternehmensgruppe ===
Re: date
От:
Ken Hill <ken@scottshill.com>
Дата:
On Fri, 2006-02-10 at 07:38 +0100, A. Kretschmer wrote:You could also try using the data_part() function:am 09.02.2006, um 22:18:09 -0800 mailte superboy143 (sent by Nabble.com) folgendes: > > 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. You can't define the format in the db, but you can define the output-format with to_char(date, 'DD-MM-YYYY'); HTH, Andreas
date_part('month',date)||-||date_part('day',date)||-||date_part('year',date)
But I think Andreas' suggestion is a bit more elegant.
Re: date
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Ken Hill writes: > On Fri, 2006-02-10 at 07:38 +0100, A. Kretschmer wrote: >> You can't define the format in the db, but you can define the >> output-format with to_char(date, 'DD-MM-YYYY'); > You could also try using the data_part() function: Setting the DateStyle parameter may also be of use, particularly on the input side. regards, tom lane
Re: date
От:
Osvaldo Rosário Kussama <osvaldo_kussama@yahoo.com.br>
Дата:
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