From: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: date problems |
Date: | 2007-08-30 13:29:47 |
Message-ID: | 20070830132947.GL4677@a-kretschmer.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Glaesemann | 2007-08-30 14:39:47 | Re: date problems |
Previous Message | ivan marchesini | 2007-08-30 13:01:03 | date problems |