From: Chris Pesko <cpesko@organic.com>
To: pgsql-admin@postgresql.org
Subject: help on to_date conversion please....
Date: Wed, 03 Apr 2002 15:13:29 -0800
Message-ID: <4.3.2.7.2.20020403150804.0464e440@mailhost.organic.com> (raw)
I am converting an 8 digit number to a date. I don't see a postgres
function to do it direct, but two functions seems like I'm on the right
track, to_char and to_date. Individually I get them to work, but when I
combine them I get the wrong answer. see below. Can anyone help in
getting the right date from an 8 digit number input formatted as yyyymmdd?
hwds=# select to_char(20020101, '99999999');
to_char
-----------
20020101 CORRECT.
(1 row)
hwds=# select to_date('20020101','yyyymmdd');
to_date
------------
2002-01-01 CORRECT.
(1 row)
hwds=# select to_date(to_char(20020101, '99999999'),'yyyymmdd');
to_date
------------
2003-08-12 WHY DOES IT GIVE ME DIFFERENT ANSWER WHEN I COMBINE THE
FUNCTIONS?
(1 row)
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-admin@postgresql.org
Cc: cpesko@organic.com
Subject: Re: help on to_date conversion please....
In-Reply-To: <4.3.2.7.2.20020403150804.0464e440@mailhost.organic.com>
References: <4.3.2.7.2.20020403150804.0464e440@mailhost.organic.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