pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kate Collins <klcollins@wsicorp.com>
To: pgsql-sql@postgresql.org
Subject: Trouble Converting Dates
Date: Tue, 07 Nov 2000 12:18:55 -0500
Message-ID: <3A08397F.D2668498@wsicorp.com> (raw)

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@wsicorp.com
PHONE:  (978) 670-5110
FAX:    (978) 670-5100
http://www.intellicast.com





Message-ID: <3A08397F.D2668498@wsicorp.com>
Permalink:  ../3A08397F.D2668498@wsicorp.com/
Also on:    postgresql.org/message-id/3A08397F.D2668498@wsicorp.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: klcollins@wsicorp.com
  Subject: Re: Trouble Converting Dates
  In-Reply-To: <3A08397F.D2668498@wsicorp.com>
  References: <3A08397F.D2668498@wsicorp.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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