Skip to content

Instantly share code, notes, and snippets.

@licvido
Created March 29, 2015 18:39
Show Gist options
  • Save licvido/fb9dbe1d10f140b0c3a5 to your computer and use it in GitHub Desktop.
Save licvido/fb9dbe1d10f140b0c3a5 to your computer and use it in GitHub Desktop.
SQL: Date table
CREATE TABLE `date` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`date` date NOT NULL,
`day` tinyint(2) unsigned NOT NULL,
`month` tinyint(2) unsigned NOT NULL,
`year` year(4) NOT NULL,
`day_of_week` tinyint(1) unsigned NOT NULL COMMENT '1 = monday, 7 = sunday',
`day_of_year` smallint(3) unsigned NOT NULL COMMENT 'starting from 0 to 365',
`week` tinyint(2) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment