-- Collection of code snippets by Arne Vajhøj 
-- posted to eksperten.dk, usenet and other places (2002-now) 
CREATE TABLE w (
    d DATE NOT NULL,
    PRIMARY KEY(d)
);

INSERT INTO w VALUES('20181226');
INSERT INTO w VALUES('20181227');
INSERT INTO w VALUES('20181228');
INSERT INTO w VALUES('20181229');
INSERT INTO w VALUES('20181230');
INSERT INTO w VALUES('20181231');
INSERT INTO w VALUES('20190101');
INSERT INTO w VALUES('20190102');
INSERT INTO w VALUES('20190103');
INSERT INTO w VALUES('20190104');
INSERT INTO w VALUES('20190105');
INSERT INTO w VALUES('20190106');

SELECT d,DAYNAME(d),YEAR(d),WEEK(d),WEEK(d,3),YEARWEEK(d),YEARWEEK(d,3) FROM w;

DROP TABLE w;
