Re: datestyle question - Mailing list pgsql-general

From Erik Jones
Subject Re: datestyle question
Date
Msg-id 8D15149E-7781-4722-BC67-37F24BE0BC03@myemma.com
Whole thread Raw
In response to datestyle question  (Diego Gil <diego@adminsa.com>)
Responses Re: datestyle question
List pgsql-general
On Sep 26, 2007, at 3:42 PM, Diego Gil wrote:

> Hi,
>
> I have a file to import to postgresql that have an unusual date
> format.
> For example, Jan 20 2007 is 20022007, in DDMMYYYY format, without any
> separator. I know that a 20072002 (YYYYMMDD) is ok, but I don't
> know how
> to handle the DDMMYYYY dates.
>
> I tried and tried but I can't import those dates to postgresql.
>
> Any hint, other than editing file ?
>
> Regards,
> Diego.

Check out the following link that explains how Postgres parses date
inputs: http://www.postgresql.org/docs/8.2/interactive/x71187.html,
particularly section 1.c

The simplest thing I can think of in your case would be to do a
little bit of text processing on that field before inserting it.  If
you simply insert dashes between the different fields so that you
have DD-MM-YYY then you can do

SET DateStyle TO 'DMY';

and then your copy should be ok.

Erik Jones

Software Developer | Emma®
erik@myemma.com
800.595.4401 or 615.292.5888
615.292.0777 (fax)

Emma helps organizations everywhere communicate & market in style.
Visit us online at http://www.myemma.com



pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: PQntuples return type
Next
From: "Scott Marlowe"
Date:
Subject: Re: datestyle question