Re: to_date

From: "Jim Fu" <Jim(dot)Fu(at)LogixCom(dot)com>
To: "Michael Fuhr" <mike(at)fuhr(dot)org>
Cc: <pgsql-admin(at)postgresql(dot)org>
Subject: Re: to_date
Date: 2006-02-13 21:22:47
Message-ID: 2BE5FA188E433143A09D9881BB923D32096F32@hou1x.Logixcom.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Thank you Michael for the info!

I have the original date info as mmddyy, when I use copy tabname from filename, it fails due to mismatch between raw date info and date data type in the database. It seems like I had to convert the raw date info to be like 'yyyy-mm-dd' to match PostgreSQL date default format in order to use copy command.

-----Original Message-----
From: Michael Fuhr [mailto:mike(at)fuhr(dot)org]
Sent: Monday, February 13, 2006 3:12 PM
To: Jim Fu
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: [ADMIN] to_date

On Mon, Feb 13, 2006 at 02:44:45PM -0600, Jim Fu wrote:
> I am new here, just wondering if PostgreSQL has a similar function
> TO_DATE ('02/12/2006','mm/dd/yyyy')?

Yes:

test=> select to_date('02/12/2006','mm/dd/yyyy');
to_date
------------
2006-02-12
(1 row)

The documentation describes the available functions; here are some
useful links:

http://www.postgresql.org/docs/
http://www.postgresql.org/docs/8.1/interactive/functions.html

Your client interface might have a way to list or search for
functions. For example, in psql you can use the \df command:

test=> \df to_date
List of functions
Schema | Name | Result data type | Argument data types
------------+---------+------------------+---------------------
pg_catalog | to_date | date | text, text
(1 row)

Are you having trouble with to_date or are you just curious? If
you're having trouble then please show what you're doing, the exact
error message or unexpected output, the version of PostgreSQL, and
the operating system name and version.

--
Michael Fuhr

Responses

  • Re: to_date at 2006-02-13 21:26:38 from Scott Marlowe

Browse pgsql-admin by date

  From Date Subject
Next Message Scott Marlowe 2006-02-13 21:26:38 Re: to_date
Previous Message Goulet, Dick 2006-02-13 21:18:30 Re: to_date