Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id D91739FB6FF for ; Thu, 30 Aug 2007 10:29:53 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 80504-03 for ; Thu, 30 Aug 2007 10:29:42 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.171]) by postgresql.org (Postfix) with ESMTP id 03E8D9FB6CC for ; Thu, 30 Aug 2007 10:29:49 -0300 (ADT) Received: from [194.25.154.138] (helo=webserv.wug.de) by mrelayeu.kundenserver.de (node=mrelayeu8) with ESMTP (Nemesis), id 0ML31I-1IQk5k09d3-0001Vz; Thu, 30 Aug 2007 15:29:48 +0200 Received: from kretschmer by webserv.wug.de with local (Exim 3.36 #1) id 1IQk5j-0004hg-00 for pgsql-sql@postgresql.org; Thu, 30 Aug 2007 15:29:47 +0200 Date: Thu, 30 Aug 2007 15:29:47 +0200 From: "A. Kretschmer" To: pgsql-sql@postgresql.org Subject: Re: date problems Message-ID: <20070830132947.GL4677@a-kretschmer.de> References: <1188478863.4876.23.camel@ivangeo> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1188478863.4876.23.camel@ivangeo> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! User-Agent: Mutt/1.5.9i X-Provags-ID: V01U2FsdGVkX1/FM69e1jNPTQHM6e+LdCXvFNpJuw0qzAgEgTr OE/MtzRE6UaFSrsOE2k9VKe2GD1RzU6lzP4qLIBnrpe9LPZ4Vp 23e4f85f8s1vjXJFPLgY1vI20YaP5ur X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/254 X-Sequence-Number: 29192 am Thu, dem 30.08.2007, um 15:01:03 +0200 mailte ivan marchesini folgendes: > Dear PG users, > I have an access db and I'm trying to pass all to postgres > I have used mdbtools to export the schema and all went quite well. > then I exported the single tables... to csv.. > > a lot of table have some timestamp fields containing data as DD/MM/YYYY, > and I'm no able to copy this table into postgres... because it needs > YYYY/MM/DD... > I used \copy... > > Which is the best solution for this problem... Change this in the csv-file with text-tools like sed or awk. Other solution: use a temp. table for input and use to_date to convert, simple example: test=> create table e (d date); CREATE TABLE test=*> create table e_temp (d text); CREATE TABLE test=*> copy e_temp from stdin; Enter data to be copied followed by a newline. End with a backslash and a period on a line by itself. >> 30/08/2007 >> \. test=*> insert into e select to_date(d, 'dd/mm/yyyy') from e_temp; INSERT 0 1 test=*> select * from e; d ------------ 2007-08-30 (1 row) Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net