El mié, 03-10-2007 a las 00:27 -0500, Erik Jones escribió:
> 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?
I am a lot more used to work with C (25+ years doing it). In fact, it is
easier to me writing it in C. That is all!. Could you post an
equivalente script, so I can try it and learn?.
"It is hard to teach new tricks to an old dog".
Regards,
Diego.