From: | Christoph Haller <ch(at)rodos(dot)fzk(dot)de> |
---|---|
To: | fduch(at)antar(dot)bryansk(dot)ru (Alexander M(dot) Pravking) |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Validity check in to_date? |
Date: | 2003-12-02 10:27:04 |
Message-ID: | 200312020927.KAA17321@rodos |
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
>
As far as I know these results are correct in terms of the underlying
C-library function mktime(). This function is intended to be used when
adding/subtracting intervals from a given timestamp.
I don't know of any postgres function doing the check you're looking for.
But I can't believe this is the first time this topic is brought up.
You may search the archives on "date plausibility" are related terms.
HTH
Regards, Christoph
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander M. Pravking | 2003-12-02 10:30:59 | Re: Validity check in to_date? |
Previous Message | CoL | 2003-12-02 10:20:54 | Re: XML & Postgres Functions |