Re: datestyle question

From: Alban Hertroys <a(dot)hertroys(at)magproductions(dot)nl>
To: Diego Gil <diego(at)adminsa(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: datestyle question
Date: 2007-09-27 08:32:53
Message-ID: 46FB6AB5.60904@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)magproductions(dot)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 //

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message detrox@gmail.com 2007-09-27 09:28:27 how to ignore invalid byte sequence for encoding without using sql_ascii?
Previous Message Johann Maar 2007-09-27 07:19:51 Re: Autostart PostgreSQL in Ubuntu