Skip site navigation (1) Skip section navigation (2)

Bug in date_part()

From: phil(at)Stimpy(dot)netroedge(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: Bug in date_part()
Date: 2001-01-16 20:09:59
Message-ID: 20010116120959.P30590@Stimpy.netroedge.com (view raw or flat)
Thread:
Lists: pgsql-bugs
Query to reproduce the bug (7.0.3):

edge=# select date_part('dow','9/1/2001'::date)::int4;
 ?column? 
----------
        6
(1 row)

edge=# select date_part('dow','4/1/2001'::date)::int4;
 ?column? 
----------
        6
(1 row)


Clearly, the first of April and September are not both on the same day
of the week. I noticed this when using some web-based calendar
software, which uses PostgreSQL as the backend, was displaying April
2001 wrong.

Here's what cal says:

# cal 2001
                               2001                                

       January               February                 March        
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa 
    1  2  3  4  5  6                1  2  3                1  2  3
 7  8  9 10 11 12 13    4  5  6  7  8  9 10    4  5  6  7  8  9 10
14 15 16 17 18 19 20   11 12 13 14 15 16 17   11 12 13 14 15 16 17
21 22 23 24 25 26 27   18 19 20 21 22 23 24   18 19 20 21 22 23 24
28 29 30 31            25 26 27 28            25 26 27 28 29 30 31

        April                   May                   June         
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa 
 1  2  3  4  5  6  7          1  2  3  4  5                   1  2
 8  9 10 11 12 13 14    6  7  8  9 10 11 12    3  4  5  6  7  8  9
15 16 17 18 19 20 21   13 14 15 16 17 18 19   10 11 12 13 14 15 16
22 23 24 25 26 27 28   20 21 22 23 24 25 26   17 18 19 20 21 22 23
29 30                  27 28 29 30 31         24 25 26 27 28 29 30

        July                  August                September      
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa 
 1  2  3  4  5  6  7             1  2  3  4                      1
 8  9 10 11 12 13 14    5  6  7  8  9 10 11    2  3  4  5  6  7  8
15 16 17 18 19 20 21   12 13 14 15 16 17 18    9 10 11 12 13 14 15
22 23 24 25 26 27 28   19 20 21 22 23 24 25   16 17 18 19 20 21 22
29 30 31               26 27 28 29 30 31      23 24 25 26 27 28 29
                                              30
       October               November               December       
Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa 
    1  2  3  4  5  6                1  2  3                      1
 7  8  9 10 11 12 13    4  5  6  7  8  9 10    2  3  4  5  6  7  8
14 15 16 17 18 19 20   11 12 13 14 15 16 17    9 10 11 12 13 14 15
21 22 23 24 25 26 27   18 19 20 21 22 23 24   16 17 18 19 20 21 22
28 29 30 31            25 26 27 28 29 30      23 24 25 26 27 28 29
                                              30 31

Otherwise, I love PostgreSQL!  An awesome backend, and knocks the
socks off MySQL for anything SQL worthy. ;')


Phil

-- 
Philip Edelbrock -- IS Manager -- Edge Design, Corvallis, OR
   phil(at)netroedge(dot)com -- http://www.netroedge.com/~phil
 PGP F16: 01 D2 FD 01 B5 46 F4 F0  3A 8B 9D 7E 14 7F FB 7A

Responses

pgsql-bugs by date

Next:From: pgsql-bugsDate: 2001-01-16 21:32:43
Subject: delete in a trigger
Previous:From: Peter T MountDate: 2001-01-16 17:21:34
Subject: Re: Fwd: JDBC buggy in 7.1beta3

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group