X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 786ED9DC9A9 for ; Fri, 10 Feb 2006 12:16:38 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 10430-08 for ; Fri, 10 Feb 2006 12:16:36 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from rwcrmhc13.comcast.net (rwcrmhc13.comcast.net [216.148.227.153]) by postgresql.org (Postfix) with ESMTP id 24C4D9DC960 for ; Fri, 10 Feb 2006 12:16:35 -0400 (AST) Received: from [10.0.1.5] (c-24-20-199-254.hsd1.or.comcast.net[24.20.199.254]) by comcast.net (rwcrmhc13) with SMTP id <20060210161634m1300rs52fe>; Fri, 10 Feb 2006 16:16:34 +0000 Subject: Re: date From: Ken Hill Reply-To: ken@scottshill.com To: "A. Kretschmer" Cc: pgsql-sql@postgresql.org In-Reply-To: <20060210063823.GC29845@webserv.wug-glas.de> References: <2865031.post@talk.nabble.com> <20060210063823.GC29845@webserv.wug-glas.de> Content-Type: multipart/alternative; boundary="=-dnr5hdKaY/gPqCaVhEEr" Organization: Scotts Hill Associates, Inc. Date: Fri, 10 Feb 2006 08:17:00 -0800 Message-Id: <1139588221.29808.7.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.061 required=5 tests=[AWL=0.060, HTML_MESSAGE=0.001] X-Spam-Score: 0.061 X-Spam-Level: X-Archive-Number: 200602/113 X-Sequence-Number: 24123 --=-dnr5hdKaY/gPqCaVhEEr Content-Type: text/plain Content-Transfer-Encoding: 7bit On Fri, 2006-02-10 at 07:38 +0100, A. Kretschmer wrote: > 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 You could also try using the data_part() function: date_part('month',date)||-||date_part('day',date)||-|| date_part('year',date) But I think Andreas' suggestion is a bit more elegant. --=-dnr5hdKaY/gPqCaVhEEr Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit On Fri, 2006-02-10 at 07:38 +0100, A. Kretschmer wrote:
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
You could also try using the data_part() function:

date_part('month',date)||-||date_part('day',date)||-||date_part('year',date)

But I think Andreas' suggestion is a bit more elegant.

--=-dnr5hdKaY/gPqCaVhEEr--