pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: A. Kretschmer <andreas.kretschmer@schollglas.com>
To: pgsql-sql@postgresql.org
Subject: Re: date problems
Date: Thu, 30 Aug 2007 15:29:47 +0200
Message-ID: <20070830132947.GL4677@a-kretschmer.de> (raw)
In-Reply-To: <1188478863.4876.23.camel@ivangeo>
References: <1188478863.4876.23.camel@ivangeo>

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



view thread (4+ messages)  latest in thread

Message-ID: <20070830132947.GL4677@a-kretschmer.de>
Permalink:  ../20070830132947.GL4677@a-kretschmer.de/
Also on:    postgresql.org/message-id/20070830132947.GL4677@a-kretschmer.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: andreas.kretschmer@schollglas.com
  Subject: Re: date problems
  In-Reply-To: <20070830132947.GL4677@a-kretschmer.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox