AD 日期的数据仓库
我们正在为世界历史数据库创建历史档案,并且需要一个引用 AD 中所有日期的日期查找表。如何为该表创建值 - 从 1AD 到 2011 年(YYYY/MM/DD)?数据库是MySQL。
问题:
我使用 Excel 预先填充日期,然后导入到 MySQL 中:YYYY/MM/DD 但 Excel 无法识别 0007、0008 等年份,因此我无法自动复制单元格生成日期。我必须手动执行此操作,这需要几天时间才能从 1AD 到 2011 年(YYYY/MM/DD)。
闰年于 1752 年引入。如果我以编程方式生成日期,如何处理 1752 年之前没有闰年的情况?它将生成错误的日期。
我的桌子:
CREATE TABLE `dates` (
`date_id` int(10) NOT NULL,
`format` char(10) NOT NULL,
`century` int(10) NOT NULL,
`decade` int(10) NOT NULL,
`year` int(10) NOT NULL,
`month` int(10) NOT NULL,
`week` int(10) NOT NULL,
`day` int(10) NOT NULL,
`month_year` int(10) NOT NULL,
`week_year` int(10) NOT NULL,
`week_month` int(10) NOT NULL,
`day_year` int(10) NOT NULL,
`day_month` int(10) NOT NULL,
`day_week` int(10) NOT NULL,
PRIMARY KEY (`date_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
We're creating a historic archive for a world history database and we need a date lookup table which references all dates in AD. How to go about creating the values for this table - from 1AD to 2011 as YYYY/MM/DD? Database is MySQL.
Problems:
I'm using Excel to pre-populate the dates, then import into MySQL as: YYYY/MM/DD but Excel doesn't recognize years like 0007, 0008, etc so I can't auto-copy cells to generate dates. I have to manually do it and this will take days to go from 1AD to year 2011 as YYYY/MM/DD.
Leap years were introduced on 1752. If I programmatically generates dates how do I handle cases prior to 1752 with no leap years? It will generate wrong dates.
My table:
CREATE TABLE `dates` (
`date_id` int(10) NOT NULL,
`format` char(10) NOT NULL,
`century` int(10) NOT NULL,
`decade` int(10) NOT NULL,
`year` int(10) NOT NULL,
`month` int(10) NOT NULL,
`week` int(10) NOT NULL,
`day` int(10) NOT NULL,
`month_year` int(10) NOT NULL,
`week_year` int(10) NOT NULL,
`week_month` int(10) NOT NULL,
`day_year` int(10) NOT NULL,
`day_month` int(10) NOT NULL,
`day_week` int(10) NOT NULL,
PRIMARY KEY (`date_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用类似这样的 SQL(使用我自己的表结构,而不是您的表结构):
Use something like this SQL (using my own table structure, not the one you had though):