Re: Date_part & cast.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christopher Sawtell <csawtell(at)xtra(dot)co(dot)nz>
Cc: Benoit Brodard <benoit(at)cyberdeck(dot)net>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Date_part & cast.
Date: 2000-04-22 23:47:51
Message-ID: 29425.956447271@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Christopher Sawtell <csawtell(at)xtra(dot)co(dot)nz> writes:
> btw, the days of the week start with Sunday = 1

Actually, date_part() seems to think Sunday = 0 ...

> However I think this demonstrates a bug in the date functions.

> chris(at)berty:~ > cal 11 1927 # In which I trust.
> November 1927
> Su Mo Tu We Th Fr Sa
> 1 2 3 4 5
> 6 7 8 9 10 11 12
> 13 14 15 16 17 18 19
> 20 21 22 23 24 25 26
> 27 28 29 30

> template1=# select date_part( 'dow', date '19271124' );
> date_part
> -----------
> 4
> (1 row)

> template1=# select date_part( 'dow', date '19271125' );
> date_part
> -----------
> 5
> (1 row)

> template1=# select date_part( 'dow', date '19271126' );
> date_part
> -----------
> 0
> (1 row)

> template1=# select date_part( 'dow', date '19271127' );
> date_part
> -----------
> 1
> (1 row)

Odd. I get 4,5,6,0, just like it should be. I am thinking you may be
seeing some problem associated with a daylight-savings transition or
some such info that Postgres gets from the local operating system.
A lot of variants of Unix have pretty unreliable timezone tables for
dates before 1970. Might want to check what your local tztab has for
1927.

I'm running on HPUX 10.20 ... and am in EST5EDT time zone ...
what about you?

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2000-04-23 00:06:07 Re: question on UPDATE rules
Previous Message Tom Lane 2000-04-22 23:09:21 Re: TOAST (was: BLOB)