Skip to content

Instantly share code, notes, and snippets.

View ngm's full-sized avatar
🙂

Neil M ngm

🙂
View GitHub Profile
@ngm
ngm / gist:69b593a5831a5b4d694e5907b8e31cc9
Created June 6, 2019 13:46 — forked from bryhal/gist:4129042
MYSQL: Generate Calendar Table
DROP TABLE IF EXISTS time_dimension;
CREATE TABLE time_dimension (
id INTEGER PRIMARY KEY, -- year*10000+month*100+day
db_date DATE NOT NULL,
year INTEGER NOT NULL,
month INTEGER NOT NULL, -- 1 to 12
day INTEGER NOT NULL, -- 1 to 31
quarter INTEGER NOT NULL, -- 1 to 4
week INTEGER NOT NULL, -- 1 to 52/53
day_name VARCHAR(9) NOT NULL, -- 'Monday', 'Tuesday'...