pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christopher Sawtell <csawtell@xtra.co.nz>
To: Benoit Brodard <benoit@cyberdeck.net>
To: pgsql-sql@postgresql.org
Subject: Re: Date_part & cast.
Date: Sat, 22 Apr 2000 11:48:40 +1200
Message-ID: <00042212582300.29813@berty> (raw)
In-Reply-To: <39000669.7F87401@cyberdeck.net>
References: <39000669.7F87401@cyberdeck.net>

On Fri, 21 Apr 2000, Benoit Brodard wrote:
> Hi,
> 
> We use PostgreSQL 6.5.3 on i586-pc-linux-gnu, compiled by gcc 2.7.2.3, and we get the following results with date_part :
> 
> db=> select date_part( 'dow', date '20000421' );
> date_part
> ---------
>         5
> (1 row)
> 
> db=> select date_part( 'dow', date ( '20000421' ) );
> date_part
> ---------
>         6
> (1 row)
> 
> Is this correct ?
No it is not.

> If yes, I could not find any explanation for the second result which also
> differ from "select date_part( 'dow', date (20000421)  );"

This, together with "hundreds" of other problems, has been fixed in
postgresql-7.0RC1. 

btw, the days of the week start with Sunday = 1

so your queries now say:-

template1=# select date_part( 'dow', date '20000421' );
 date_part
-----------
         6
(1 row)
 
template1=# select date_part( 'dow', date ( '20000421' ) );
 date_part
-----------
         6
(1 row)

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)
                                                                                  
There seems to be a discontinuity here doesn't there?

Using postgresql-7.0RC1.

If somebody could direct me to the general area in the source tree, I might be
able to come up with a patch & btw, to whom should I send it?

-- 
Sincerely etc.,

 NAME       Christopher Sawtell - iOpen Technologies Ltd.
 CELL PHONE 021 257 4451
 ICQ UIN    45863470
 EMAIL      chris @ iopen . co . nz,  csawtell @ xtra . co . nz
 WWW        http://www.iopen.co.nz
 CNOTES     ftp://ftp.funet.fi/pub/languages/C/tutorials/sawtell_C.tar.gz

 -->> Please refrain from using HTML or WORD attachments in e-mails to me <<--




view thread (4+ messages)  latest in thread

Message-ID: <00042212582300.29813@berty>
Permalink:  ../00042212582300.29813@berty/
Also on:    postgresql.org/message-id/00042212582300.29813@berty

 · 

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: csawtell@xtra.co.nz, benoit@cyberdeck.net
  Subject: Re: Date_part & cast.
  In-Reply-To: <00042212582300.29813@berty>
  References: <39000669.7F87401@cyberdeck.net> <00042212582300.29813@berty>

* 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