Re: datestyle question

From: Erik Jones <erik(at)myemma(dot)com>
To: Diego Gil <diego(at)adminsa(dot)com>
Cc: Alban Hertroys <a(dot)hertroys(at)magproductions(dot)nl>, pgsql-general(at)postgresql(dot)org
Subject: Re: datestyle question
Date: 2007-10-03 05:27:43
Message-ID: E6A2A28E-5479-41F0-912D-2EED60D7AFDC@myemma.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)myemma(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2007-10-03 05:49:03 Re: Find out encoding of data
Previous Message dterrors 2007-10-03 03:58:38 Re: It's time to support GRANT SELECT, UPDATE, ..., ..., ... ON database.* to username