Re: datestyle question - Mailing list pgsql-general

From Alban Hertroys
Subject Re: datestyle question
Date
Msg-id 46FB6AB5.60904@magproductions.nl
Whole thread Raw
In response to datestyle question  (Diego Gil <diego@adminsa.com>)
Responses Re: datestyle question
List pgsql-general
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:

insert into my_table (my_date_field)
select to_date(my_date_text_field, 'DDMMYYYY') - interval '1 month'
  from my_temp_table;

Regards,
--
Alban Hertroys
alban@magproductions.nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
   7500 AK Enschede

// Integrate Your World //

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: PQntuples return type
Next
From: "Peter Childs"
Date:
Subject: Re: Performance Issues