Inconsistant DOW...

From: "W(dot)B(dot)Hill" <bill(at)hillzaa1(dot)miniserver(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Inconsistant DOW...
Date: 2004-06-28 16:23:25
Message-ID: Pine.LNX.4.58.0406281616130.20175@uvyymnn1.zvavfreire.pbz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hiya!

What's happening, where've I goofed?

CREATE TABLE test (d date);

INSERT INTO test(d) VALUES('11-Apr-2004');
INSERT INTO test(d) VALUES('27-Mar-2005');
INSERT INTO test(d) VALUES('16-Apr-2006');
INSERT INTO test(d) VALUES('08-Apr-2007');
INSERT INTO test(d) VALUES('23-Mar-2008');
INSERT INTO test(d) VALUES('12-Apr-2009');
INSERT INTO test(d) VALUES('04-Apr-2010');

SELECT * FROM test;
d
------------
2004-04-11
2005-03-27
2006-04-16
2007-04-08
2008-03-23
2009-04-12
2010-04-04
(7 rows)

SELECT date_part('dow',d) FROM test;
date_part
-----------
0
0
0
0
0
0
0
(7 rows)

This is good - every Easter's on a Sunday so far...

SELECT d+'45 days ago'::interval FROM test;
?column?
------------------------
2004-02-25 23:00:00+00
2005-02-10 00:00:00+00
2006-03-01 23:00:00+00
2007-02-21 23:00:00+00
2008-02-07 00:00:00+00
2009-02-25 23:00:00+00
2010-02-17 23:00:00+00
(7 rows)

Why the different times??? Why the times???

SELECT date_part('dow',d+'45 days ago'::interval) FROM test;
date_part
-----------
3
4
3
3
4
3
3
(7 rows)

So, Ash Wednesday's on a Thursday iff Easter's in March???
Hmmm.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adam Ruth 2004-06-28 16:37:11 Re: Group by - Case insensitivity
Previous Message Thomas Hallgren 2004-06-28 15:32:55 Re: Plperlu and sending emails, is it safe?