[SQL] to_date/to timestamp going to BC

2001-10-03 Thread jason . servetar

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, '), to_timestamp(dt, 'Month dd,
') 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)




---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



Re: [SQL] to_date/to timestamp going to BC

2001-10-04 Thread jason . servetar

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:[EMAIL PROTECTED]]
Sent: Thursday, October 04, 2001 2:42 AM
To: Tom Lane
Cc: Servetar, Jason; [EMAIL PROTECTED]
Subject: Re: [SQL] to_date/to timestamp going to BC


On Wed, Oct 03, 2001 at 05:14:02PM -0400, Tom Lane wrote:
> [EMAIL PROTECTED] 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, ') 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, ') 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  <[EMAIL PROTECTED]>
 http://home.zf.jcu.cz/~zakkr/
 
 C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]



Re: [SQL] to_date/to timestamp going to BC

2001-10-03 Thread jason . servetar

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, ') 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:[EMAIL PROTECTED]]
Sent: Wednesday, October 03, 2001 3:14 PM
To: Servetar, Jason
Cc: [EMAIL PROTECTED]
Subject: Re: [SQL] to_date/to timestamp going to BC 


[EMAIL PROTECTED] 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, ') 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

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html