Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id TAA82760 for ; Sat, 22 Apr 2000 19:48:24 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id TAA29428; Sat, 22 Apr 2000 19:47:51 -0400 (EDT) To: Christopher Sawtell cc: Benoit Brodard , pgsql-sql@postgresql.org Subject: Re: Date_part & cast. In-reply-to: <00042212582300.29813@berty> References: <39000669.7F87401@cyberdeck.net> <00042212582300.29813@berty> Comments: In-reply-to Christopher Sawtell message dated "Sat, 22 Apr 2000 11:48:40 +1200" Date: Sat, 22 Apr 2000 19:47:51 -0400 Message-ID: <29425.956447271@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200004/258 Christopher Sawtell 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@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