Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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;

Alban Hertroys

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
A: Postbus 416
   7500 AK Enschede

// Integrate Your World //

In response to


pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group