From: Karel Zak <zakkr@zf.jcu.cz>
To: leif@danmos.dk
Cc: pgsql-interfaces@postgresql.org
Subject: Re: to_date problem
Date: Thu, 15 Mar 2001 11:27:48 +0100
Message-ID: <20010315112748.B28603@ara.zf.jcu.cz> (raw)
In-Reply-To: <200103150737.f2F7bQl13172@crysberg.dk>
References: <200103150737.f2F7bQl13172@crysberg.dk>
On Thu, Mar 15, 2001 at 08:37:26AM +0100, leif@danmos.dk wrote:
>
> Hello,
>
> I have just observed the following problem:
>
> -------------------------------------------------------------------
> testdb=# select to_date('2001-3-5 10:00', 'YYYY-MM-DD HH24:MI') from dual;
> to_date
> ------------
> 2001-03-10
> (1 row)
>
Hmm .. because 'MM'and 'DD' expect two digits, more correct is en example
(without Oracle's fundamental "from dual" :-)
test=# select to_date('2001-03-05 10:00', 'YYYY-MM-DD HH24:MI');
to_date
------------
2001-03-05
(1 row)
or you can use 'FM' - "fill mode" switch:
test=# select to_date('2001-3-5 10:00', 'YYYY-FMMM-FMDD HH24:MI');
to_date
------------
2001-03-05
(1 row)
The common rule: data that you want parse in to_date() must be formatted
like output from to_char() with same format mask. The to_char() never output
'2001-3-5 10:00' for 'YYYY-MM-DD HH24:MI'.
Hmm, now I see Oracle and it allows correct parse this dirty query...
SVRMGR> select to_date('2001-3-5 10:00', 'YYYY-FMMM-FMDD HH24:MI') from
dual;
TO_DATE('
---------
05-MAR-01
1 row selected.
..but nothing say Oracle's documentation about this (IMHO). Well I add it
to my TODO for 7.2, but it's prop for users those not reading docs...
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
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 using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: zakkr@zf.jcu.cz, leif@danmos.dk
Subject: Re: to_date problem
In-Reply-To: <20010315112748.B28603@ara.zf.jcu.cz>
* 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