Re: Strange results from to_timestamp

From: "William ZHANG" <uniware(at)zedware(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Strange results from to_timestamp
Date: 2006-04-06 15:30:22
Message-ID: e13c54$11g7$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

ISTM, and mismatch between the date/time string and the format string will
lead to
strange results.
The source code of to_timestamp() is in src/backend/utils/adt/formatting.c:

Datum
to_timestamp(PG_FUNCTION_ARGS)

Regards,
William ZHANG

"Mario Weilguni" <mweilguni(at)sime(dot)com>
> Am Donnerstag, 6. April 2006 14:57 schrieb Mario Weilguni:
> > mydb=# select to_timestamp('00000000 0300','yyyymmdd hh24mi');
> > to_timestamp
> > ---------------------------
> > 0001-01-01 03:00:00+01 BC
> > (1 row)
> >
> > Questionable, but probably valid.
> >
> >
> >
> > mydb=# select to_timestamp(' 0300','yyyymmdd hh24mi');
> > to_timestamp
> > ------------------------
> > 0300-12-25 03:00:00+01
> > (1 row)
> >
> > This puzzles me. Where is the 25th of december coming from?
>
> Sorry, forgot to mention, this is from PostgreSQL 8.1.3
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Patrick Welche 2006-04-06 16:39:37 Re: Summer of Code Preparation
Previous Message Andrew Dunstan 2006-04-06 15:18:29 Re: About pg_hba.conf