pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Christopher Sawtell <csawtell@xtra.co.nz>
Cc: Benoit Brodard <benoit@cyberdeck.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Date_part & cast.
Date: Sat, 22 Apr 2000 19:47:51 -0400
Message-ID: <29425.956447271@sss.pgh.pa.us> (raw)
In-Reply-To: <00042212582300.29813@berty>
References: <39000669.7F87401@cyberdeck.net>
	<00042212582300.29813@berty>

Christopher Sawtell <csawtell@xtra.co.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@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



view thread (4+ messages)  latest in thread

Message-ID: <29425.956447271@sss.pgh.pa.us>
Permalink:  ../29425.956447271@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/29425.956447271@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, csawtell@xtra.co.nz, benoit@cyberdeck.net
  Subject: Re: Date_part & cast.
  In-Reply-To: <29425.956447271@sss.pgh.pa.us>
  References: <39000669.7F87401@cyberdeck.net> <00042212582300.29813@berty> <29425.956447271@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox