pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedto_date/to timestamp going to BC
7+ messages / 4 participants
[nested] [flat]
* to_date/to timestamp going to BC
@ 2001-10-03 20:22 jason.servetar@ccgenesis.com
2001-10-03 21:14 ` Re: to_date/to timestamp going to BC Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 7+ messages in thread
From: jason.servetar@ccgenesis.com @ 2001-10-03 20:22 UTC (permalink / raw)
To: pgsql-sql
Can someone tell me if this is a bug with the date functions or am I using
them incorrectly?
If anyone has a workaround for this I could use some help this data
conversion.
dev=> create table test_date (dt varchar(100));
CREATE
dev=> insert into test_date values ('March 11, 1997');
INSERT 706020 1
dev=> select dt, to_date(dt, 'Month dd, yyyy'), to_timestamp(dt, 'Month dd,
yyyy') from test_date;
dt | to_date | to_timestamp
----------------+---------------+---------------
March 11, 1997 | 0001-03-19 BC | 0001-03-19 BC
drw_dev=> select version();
version
----------------------------------------------------------------
PostgreSQL 7.1 on sparc-sun-solaris2.6, compiled by GCC 2.95.2
(1 row)
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: to_date/to timestamp going to BC
2001-10-03 20:22 to_date/to timestamp going to BC jason.servetar@ccgenesis.com
@ 2001-10-03 21:14 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-10-04 08:41 ` Re: to_date/to timestamp going to BC Karel Zak <zakkr@zf.jcu.cz>
0 siblings, 1 reply; 7+ messages in thread
From: Tom Lane @ 2001-10-03 21:14 UTC (permalink / raw)
To: jason.servetar@ccgenesis.com; +Cc: pgsql-sql
jason.servetar@ccgenesis.com writes:
> Can someone tell me if this is a bug with the date functions or am I using
> them incorrectly?
I get the right thing when I use the right format:
regression=# select dt, to_timestamp(dt, 'FMMonth dd, yyyy') from test_date;
dt | to_timestamp
----------------+------------------------
March 11, 1997 | 1997-03-11 00:00:00-05
(1 row)
However, I'd agree that this shows a lack of robustness in to_timestamp;
it's not objecting to data that doesn't match the format.
regards, tom lane
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: to_date/to timestamp going to BC
2001-10-03 20:22 to_date/to timestamp going to BC jason.servetar@ccgenesis.com
2001-10-03 21:14 ` Re: to_date/to timestamp going to BC Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-10-04 08:41 ` Karel Zak <zakkr@zf.jcu.cz>
2001-10-04 14:44 ` Re: to_date/to timestamp going to BC Josh Berkus <josh@agliodbs.com>
0 siblings, 1 reply; 7+ messages in thread
From: Karel Zak @ 2001-10-04 08:41 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: jason.servetar@ccgenesis.com; pgsql-sql
On Wed, Oct 03, 2001 at 05:14:02PM -0400, Tom Lane wrote:
> jason.servetar@ccgenesis.com writes:
> > Can someone tell me if this is a bug with the date functions or am I using
> > them incorrectly?
>
> I get the right thing when I use the right format:
>
> regression=# select dt, to_timestamp(dt, 'FMMonth dd, yyyy') from test_date;
> dt | to_timestamp
> ----------------+------------------------
> March 11, 1997 | 1997-03-11 00:00:00-05
> (1 row)
>
> However, I'd agree that this shows a lack of robustness in to_timestamp;
> it's not objecting to data that doesn't match the format.
The manual is transparent about this. I can add feauture that will
check everythig, but users who knows read manual and use already
debugged queries will spend CPU on non-wanted code.
Hmm.. I look at Oracle, and it allows parse queries like:
SVRMGR> select to_date('March 11, 1997', 'Month dd, yyyy') from dual;
TO_DATE('
---------
11-MAR-97
1 row selected.
.. well, I add it to my TODO for 7.3 (I plan rewrite several things
in to_* functions).
Karel
--
Karel Zak <zakkr@zf.jcu.cz>
http://home.zf.jcu.cz/~zakkr/
C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: to_date/to timestamp going to BC
2001-10-03 20:22 to_date/to timestamp going to BC jason.servetar@ccgenesis.com
2001-10-03 21:14 ` Re: to_date/to timestamp going to BC Tom Lane <tgl@sss.pgh.pa.us>
2001-10-04 08:41 ` Re: to_date/to timestamp going to BC Karel Zak <zakkr@zf.jcu.cz>
@ 2001-10-04 14:44 ` Josh Berkus <josh@agliodbs.com>
2001-10-04 14:56 ` Re: to_date/to timestamp going to BC Karel Zak <zakkr@zf.jcu.cz>
0 siblings, 1 reply; 7+ messages in thread
From: Josh Berkus @ 2001-10-04 14:44 UTC (permalink / raw)
To: Karel Zak <zakkr@zf.jcu.cz>; pgsql-sql
Karel,
> .. well, I add it to my TODO for 7.3 (I plan rewrite several things
> in to_* functions).
How about a to_char function for INTERVAL? Please, oh please?
-Josh
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh@agliodbs.com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: to_date/to timestamp going to BC
2001-10-03 20:22 to_date/to timestamp going to BC jason.servetar@ccgenesis.com
2001-10-03 21:14 ` Re: to_date/to timestamp going to BC Tom Lane <tgl@sss.pgh.pa.us>
2001-10-04 08:41 ` Re: to_date/to timestamp going to BC Karel Zak <zakkr@zf.jcu.cz>
2001-10-04 14:44 ` Re: to_date/to timestamp going to BC Josh Berkus <josh@agliodbs.com>
@ 2001-10-04 14:56 ` Karel Zak <zakkr@zf.jcu.cz>
0 siblings, 0 replies; 7+ messages in thread
From: Karel Zak @ 2001-10-04 14:56 UTC (permalink / raw)
To: Josh Berkus <josh@agliodbs.com>; +Cc: pgsql-sql
On Thu, Oct 04, 2001 at 07:44:14AM -0700, Josh Berkus wrote:
> Karel,
>
> > .. well, I add it to my TODO for 7.3 (I plan rewrite several things
> > in to_* functions).
>
> How about a to_char function for INTERVAL? Please, oh please?
oh, needn't please.. already in right now breeding 7.2 :-)
test=# SELECT to_char('5months 3sec 4h 1min'::interval, 'HH:MI:SS Mon');
to_char
--------------
04:01:03 May
(1 row)
Karel
--
Karel Zak <zakkr@zf.jcu.cz>
http://home.zf.jcu.cz/~zakkr/
C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: to_date/to timestamp going to BC
@ 2001-10-03 21:36 jason.servetar@ccgenesis.com
0 siblings, 0 replies; 7+ messages in thread
From: jason.servetar@ccgenesis.com @ 2001-10-03 21:36 UTC (permalink / raw)
To: pgsql-sql
Thanks Tom that worked great.
I guess I should have not skipped the
FM prefix section of the date conversion doc.
drw_dev-> to_timestamp(dt, 'FMMonth dd, yyyy') from test_date;
dt | to_date | to_timestamp
----------------+------------+------------------------
March 11, 1997 | 1997-03-11 | 1997-03-11 00:00:00-07
-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Wednesday, October 03, 2001 3:14 PM
To: Servetar, Jason
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] to_date/to timestamp going to BC
jason.servetar@ccgenesis.com writes:
> Can someone tell me if this is a bug with the date functions or am I using
> them incorrectly?
I get the right thing when I use the right format:
regression=# select dt, to_timestamp(dt, 'FMMonth dd, yyyy') from test_date;
dt | to_timestamp
----------------+------------------------
March 11, 1997 | 1997-03-11 00:00:00-05
(1 row)
However, I'd agree that this shows a lack of robustness in to_timestamp;
it's not objecting to data that doesn't match the format.
regards, tom lane
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: to_date/to timestamp going to BC
@ 2001-10-04 19:59 jason.servetar@ccgenesis.com
0 siblings, 0 replies; 7+ messages in thread
From: jason.servetar@ccgenesis.com @ 2001-10-04 19:59 UTC (permalink / raw)
To: pgsql-sql
Thanks Karel,
Good call, you guessed it. I was just using my Oracle knowledge of
the to_date and applying it to the results I was expecting in pgsql. Guess I
should not make those assumptions....
-----Original Message-----
From: Karel Zak [mailto:zakkr@zf.jcu.cz]
Sent: Thursday, October 04, 2001 2:42 AM
To: Tom Lane
Cc: Servetar, Jason; pgsql-sql@postgresql.org
Subject: Re: [SQL] to_date/to timestamp going to BC
On Wed, Oct 03, 2001 at 05:14:02PM -0400, Tom Lane wrote:
> jason.servetar@ccgenesis.com writes:
> > Can someone tell me if this is a bug with the date functions or am I
using
> > them incorrectly?
>
> I get the right thing when I use the right format:
>
> regression=# select dt, to_timestamp(dt, 'FMMonth dd, yyyy') from
test_date;
> dt | to_timestamp
> ----------------+------------------------
> March 11, 1997 | 1997-03-11 00:00:00-05
> (1 row)
>
> However, I'd agree that this shows a lack of robustness in to_timestamp;
> it's not objecting to data that doesn't match the format.
The manual is transparent about this. I can add feauture that will
check everythig, but users who knows read manual and use already
debugged queries will spend CPU on non-wanted code.
Hmm.. I look at Oracle, and it allows parse queries like:
SVRMGR> select to_date('March 11, 1997', 'Month dd, yyyy') from dual;
TO_DATE('
---------
11-MAR-97
1 row selected.
.. well, I add it to my TODO for 7.3 (I plan rewrite several things
in to_* functions).
Karel
--
Karel Zak <zakkr@zf.jcu.cz>
http://home.zf.jcu.cz/~zakkr/
C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2001-10-04 19:59 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-10-03 20:22 to_date/to timestamp going to BC jason.servetar@ccgenesis.com
2001-10-03 21:14 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-10-04 08:41 ` Karel Zak <zakkr@zf.jcu.cz>
2001-10-04 14:44 ` Josh Berkus <josh@agliodbs.com>
2001-10-04 14:56 ` Karel Zak <zakkr@zf.jcu.cz>
2001-10-03 21:36 Re: to_date/to timestamp going to BC jason.servetar@ccgenesis.com
2001-10-04 19:59 Re: to_date/to timestamp going to BC jason.servetar@ccgenesis.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