Trouble Converting Dates

From: Kate Collins <klcollins(at)wsicorp(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Trouble Converting Dates
Date: 2000-11-07 17:18:55
Message-ID: 3A08397F.D2668498@wsicorp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi

I am running postgres 7.02 on Linux and I am having trouble converting a

character string to a date using the "to_date" function.

For example:

select to_char( to_date( '001112', 'YYMMDD'), 'YYYYMMDD');
to_char
----------
00001112

In other words it is defaulting to the year 0 (actually year 1 BC, since

there is no year 0) instead of 2000.

Now I run the equivalent select statement on Oracle, and I get:

select to_char( to_date( '001112', 'YYMMDD'), 'YYYYMMDD') from dual;

TO_CHAR(TO_DATE('001112','YYMMDD'),'YYYYMMDD')
---------------------------------------------------------------------------

20001112

Which is what I expect.

Is "YY" suppose to default to the current century or is this an
Oracle'ism?

I looked in my Postgres documents for a table describing the Date
conversion strings, and could not find one. Is there a reference some
one can direct me to?

BTW, on postgres, when I try:

select to_char( to_date( '20001112', 'YYYYMMDD'), 'YYYYMMDD');

I get the error: "ERROR: Unable to convert timestamp to date"

Thanks,
Kate

--
=================================================
Katherine (Kate) L. Collins
Senior Software Engineer/Meteorologist
Weather Services International (WSI Corporation)
4 Federal Street
Billerica, MA 01821
EMAIL: klcollins(at)wsicorp(dot)com
PHONE: (978) 670-5110
FAX: (978) 670-5100
http://www.intellicast.com

Browse pgsql-sql by date

  From Date Subject
Next Message Brian Powell 2000-11-07 17:45:56 Cascading a pseudo-delete?
Previous Message Edmar Wiggers 2000-11-07 16:55:20 RE: reinitialise serial counter