Validity check in to_date?

From: "Alexander M(dot) Pravking" <fduch(at)antar(dot)bryansk(dot)ru>
To: pgsql-sql(at)postgresql(dot)org
Subject: Validity check in to_date?
Date: 2003-11-27 14:11:25
Message-ID: 20031127141125.GC87728@dyatel.antar.bryansk.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I just discovered that to_date() function does not check if supplied
date is correct, giving surprising (at least for me) results:

fduch=# SELECT to_date('31.11.2003', 'DD.MM.YYYY');
to_date
------------
2003-12-01

or even

fduch=# SELECT to_date('123.45.2003', 'DD.MM.YYYY');
to_date
------------
2007-01-03

to_timestamp() seems to work the same way. It's probably useful sometimes,
but not in my case... Is it how it supposed to work?
If so, how can I do such a validity check?
If not, has something changed in 7.4?

In any case, I have to find a workaround now and will appreciate any help.

fduch=# SELECT version();
version
---------------------------------------------------------------------
PostgreSQL 7.3.4 on i386-portbld-freebsd4.8, compiled by GCC 2.95.4

--
Fduch M. Pravking

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Joe Conway 2003-11-27 15:57:08 Re: Scaler forms as function arguments
Previous Message Christoph Haller 2003-11-27 11:05:40 Re: Problem: Postgresql not starting