pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedto_date
6+ messages / 4 participants
[nested] [flat]
* to_date
@ 2006-02-13 20:44 Jim Fu <Jim.Fu@LogixCom.com>
2006-02-13 21:11 ` Re: to_date Michael Fuhr <mike@fuhr.org>
0 siblings, 1 reply; 6+ messages in thread
From: Jim Fu @ 2006-02-13 20:44 UTC (permalink / raw)
To: pgsql-admin
I am new here, just wondering if PostgreSQL has a similar function TO_DATE ('02/12/2006','mm/dd/yyyy')?
Thanks!
Jim Fu
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: to_date
2006-02-13 20:44 to_date Jim Fu <Jim.Fu@LogixCom.com>
@ 2006-02-13 21:11 ` Michael Fuhr <mike@fuhr.org>
0 siblings, 0 replies; 6+ messages in thread
From: Michael Fuhr @ 2006-02-13 21:11 UTC (permalink / raw)
To: Jim Fu <Jim.Fu@LogixCom.com>; +Cc: pgsql-admin
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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: to_date
@ 2006-02-13 21:18 Goulet, Dick <DGoulet@vicr.com>
2006-02-14 01:13 ` Re: to_date Michael Fuhr <mike@fuhr.org>
0 siblings, 1 reply; 6+ messages in thread
From: Goulet, Dick @ 2006-02-13 21:18 UTC (permalink / raw)
To: Jim Fu <Jim.Fu@LogixCom.com>; pgsql-admin
If your using V7.4 it doesn't but the following will create one.
CREATE OR REPLACE FUNCTION to_date(text, text)
RETURNS "timestamp" AS
'begin
return to_timestamp($1, $2);
end;'
LANGUAGE 'plpgsql' STABLE STRICT;
_____
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Jim Fu
Sent: Monday, February 13, 2006 3:45 PM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] to_date
I am new here, just wondering if PostgreSQL has a similar function
TO_DATE ('02/12/2006','mm/dd/yyyy')?
Thanks!
Jim Fu
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: to_date
2006-02-13 21:18 Re: to_date Goulet, Dick <DGoulet@vicr.com>
@ 2006-02-14 01:13 ` Michael Fuhr <mike@fuhr.org>
0 siblings, 0 replies; 6+ messages in thread
From: Michael Fuhr @ 2006-02-14 01:13 UTC (permalink / raw)
To: Goulet, Dick <DGoulet@vicr.com>; +Cc: Jim Fu <Jim.Fu@logixcom.com>; pgsql-admin
On Mon, Feb 13, 2006 at 04:18:30PM -0500, Goulet, Dick wrote:
> If your using V7.4 it doesn't but the following will create one.
Eh? to_date(text, text) is documented as far back as 7.0, and it
certainly works on the 7.4 and 7.3 systems I checked.
http://www.postgresql.org/docs/7.4/static/functions-formatting.html
http://www.postgresql.org/docs/7.3/static/functions-formatting.html
http://www.postgresql.org/docs/7.2/static/functions-formatting.html
http://www.postgresql.org/docs/7.1/static/functions-formatting.html
http://www.postgresql.org/docs/7/static/functions2976.htm
--
Michael Fuhr
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: to_date
@ 2006-02-13 21:22 Jim Fu <Jim.Fu@LogixCom.com>
2006-02-13 21:26 ` Re: to_date Scott Marlowe <smarlowe@g2switchworks.com>
0 siblings, 1 reply; 6+ messages in thread
From: Jim Fu @ 2006-02-13 21:22 UTC (permalink / raw)
To: Michael Fuhr <mike@fuhr.org>; +Cc: 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@fuhr.org]
Sent: Monday, February 13, 2006 3:12 PM
To: Jim Fu
Cc: pgsql-admin@postgresql.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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: to_date
2006-02-13 21:22 Re: to_date Jim Fu <Jim.Fu@LogixCom.com>
@ 2006-02-13 21:26 ` Scott Marlowe <smarlowe@g2switchworks.com>
0 siblings, 0 replies; 6+ messages in thread
From: Scott Marlowe @ 2006-02-13 21:26 UTC (permalink / raw)
To: Jim Fu <Jim.Fu@LogixCom.com>; +Cc: Michael Fuhr <mike@fuhr.org>; pgsql-admin
On Mon, 2006-02-13 at 15:22, Jim Fu wrote:
> 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.
Take a look here:
http://www.postgresql.org/docs/8.1/static/runtime-config-client.html#GUC-DATESTYLE
and here:
http://www.postgresql.org/docs/8.1/static/datatype-datetime.html
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2006-02-14 01:13 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-02-13 20:44 to_date Jim Fu <Jim.Fu@LogixCom.com>
2006-02-13 21:11 ` Michael Fuhr <mike@fuhr.org>
2006-02-13 21:18 Re: to_date Goulet, Dick <DGoulet@vicr.com>
2006-02-14 01:13 ` Michael Fuhr <mike@fuhr.org>
2006-02-13 21:22 Re: to_date Jim Fu <Jim.Fu@LogixCom.com>
2006-02-13 21:26 ` Scott Marlowe <smarlowe@g2switchworks.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox