Re: datestyle question - Mailing list pgsql-general

From Erik Jones
Subject Re: datestyle question
Date
Msg-id E6A2A28E-5479-41F0-912D-2EED60D7AFDC@myemma.com
Whole thread Raw
In response to Re: datestyle question  (Diego Gil <diego@adminsa.com>)
Responses Re: datestyle question  (Diego Gil <diego@adminsa.com>)
List pgsql-general
On Oct 2, 2007, at 8:56 PM, Diego Gil wrote:

> El jue, 27-09-2007 a las 10:32 +0200, Alban Hertroys escribió:
>> 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.
>>
>> You could try importing those fields in a text field in a temporary
>> table and then convert them from there into your final tables
>> using the
>> to_date() function.
>>
>> If 20022007 really means 20 Jan instead of 20 Feb, try something
>> like:
>>
> No, it realy means 20 Feb. My mistake !.
>
>
>> insert into my_table (my_date_field)
>> select to_date(my_date_text_field, 'DDMMYYYY') - interval '1 month'
>>   from my_temp_table;
>>
>> Regards,
>
> I finally ended coding a dirty C program to reverse the order of date
> fields. Here is the code, in case anyone need it.

I'm glad you got something working.  However, out of morbid
curiousity I have to ask:  why did you use C for that when you could
have done it with at most a three line script or even one line
directly from the shell?

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: Diego Gil
Date:
Subject: Re: datestyle question
Next
From: "Albe Laurenz"
Date:
Subject: Re: Find out encoding of data