用Python判断节假日,以及节假日的SQL数据文件

为什么要判断节假日?

在我们的日常生活中,节假日是一个重要的组成部分。无论是个人计划还是商业活动,了解特定日期是否为节假日都是非常有用的。在Python中,我们可以使用一些内置的日期和时间模块来判断一个日期是否是法定节假日。

在数据分析工作中,判断节假日的使用场景主要有以下几个方面:

  1. 销售数据分析:对于电商或线下零售商来说,节假日的销售数据可能与其他时间有所不同。通过判断节假日,可以对销售数据进行更准确的趋势分析和预测。
  2. 用户行为分析:在用户行为分析中,节假日的影响可能导致用户行为的变化。例如,节假日期间用户可能更倾向于浏览娱乐内容或进行短途旅行。
  3. 流量分析:对于许多在线业务,例如旅游、电影票预订或在线游戏等,节假日的流量波动是一个重要的分析点。通过判断节假日,可以更好地了解流量变化和用户需求。
  4. 媒体内容推荐:根据节假日的特点,可以为用户推荐相应主题的内容或广告。例如,在春节期间可以加强推荐与家人团聚或相关节日文化的内容。
  5. 市场活动规划:对于市场营销团队来说,节假日是策划活动的好时机。通过判断节假日,可以更精准地定位目标受众和制定营销策略。
  6. 物流配送优化:在物流和配送领域,节假日可能导致配送需求的增加或配送时间的延长。通过判断节假日,可以更好地规划运力和优化配送路线。
  7. 客户服务响应:在客户服务方面,节假日可能导致服务需求的增加或响应时间的延长。通过判断节假日,可以更好地调配资源和服务人员。
  8. 趋势预测:通过判断节假日,可以更准确地预测业务发展趋势和市场变化。例如,对于酒店业,可以利用历史数据预测节假日期间的入住率和房价。
  9. 安全风险预警:在某些领域,例如金融或网络安全,节假日可能带来更多的安全风险。通过数据分析,可以提前发现潜在的安全威胁并进行预警。

综上所述,判断节假日在数据分析工作中具有广泛的应用场景。通过合理利用节假日数据,可以更好地理解用户需求和市场变化,提高业务运营的效率和效果。

python如何判断节假日?

首先,我们需要导入Python的datetime模块。这个模块提供了日期和时间的各种操作,包括日期的比较、计算等。

然后,我们还需要安装chinesecalendar模块,这个模块提供判断某年某月某一天是不是工作日/节假日。 支持 2004年 至 2024年,包括 2020年 的春节延长。

import datetime

from chinese_calendar import is_holiday, is_workday
from chinese_calendar.constants import workdays, holidays

安装chinesecalendar

pip install chinesecalendar

更新chinesecalendar

pip install -U chinesecalendar

由于次年的节假日安排,取决于国务院发布的日程。 所以本项目一般会在国务院更新以后,发布新的版本。 按照以往的经验,一般是每年的 11月 前后发布新版本。

判断节假日和工作日

接下来,我们可以使用is_holiday和is_workday来判断给定的日期是否是法定节假日。

这两个函数接受一个日期对象作为参数,并返回一个布尔值来表示该日期是否为法定节假日。

现在,我们可以使用这个函数来判断任意给定的日期是否是法定节假日。例如:

import datetime

from chinese_calendar import is_holiday, is_workday
from chinese_calendar.constants import workdays, holidays

# 获取当前日期
now_ = datetime.datetime.now()

# 判断当天是否是工作日【正常周内、调休都是工作日】
print(now_.strftime("%Y-%m-%d"), "是否是工作日:", is_workday(now_))

# 判断当天是否是节假日【正常周末、放假都是节假日】
print(now_.strftime("%Y-%m-%d"), "是否是节假日:", is_holiday(now_))

# 判断指定日期是节假日还是工作日
someday = datetime.date(2024, 2, 10)
print(someday.strftime("%Y-%m-%d"), "是否是工作日:", is_workday(someday))
print(someday.strftime("%Y-%m-%d"), "是否是节假日:", is_holiday(someday))

这个示例代码演示了如何使用Python的chinese_calendar模块来判断一个日期是否是法定节假日。你可以根据自己的需求修改日期来使用。

如何修改为SQL数据?

SQL是数据分析中常用的工具,于是乎,我将这些【节假日】、【调休日期】转化为sql语句,并保存到对应的sql文件中,具体代码如下:

import datetime

from chinese_calendar import is_holiday, is_workday
from chinese_calendar.constants import workdays, holidays

# 节假日的中英文名称
day_name_list = [
    ("New Year's Day", "元旦", 1),
    ("Spring Festival", "春节", 3),
    ("Tomb-sweeping Day", "清明", 1),
    ("Labour Day", "劳动节", 1),
    ("Dragon Boat Festival", "端午", 1),
    ("National Day", "国庆节", 3),
    ("Mid-autumn Festival", "中秋", 1)
]
# 制作节假日sql语句
holidays_sql = """insert into holidays(holiday,english_name,chinese_name) values """
for k, v in holidays.items():
    for h in day_name_list:
        if v == h[0]:
            holidays_sql += str(tuple((k.strftime("%Y-%m-%d"), v.replace("'", ""), h[1]))) + ",\n"
            continue
# 替换最后一个逗号为分号
holidays_sql = holidays_sql[:-2] + ";"
with open("./holidays_value.sql", "w", encoding="utf-8") as f:
    f.write(holidays_sql)
    print("holidays_sql写入文件holidays_value.sql成功!")

# 制作调休sql语句
workdays_sql = """insert into workdays(workday,english_name,chinese_name) values """
for k, v in workdays.items():
    for h in day_name_list:
        if v == h[0]:
            workdays_sql += str(tuple((k.strftime("%Y-%m-%d"), v.replace("'", ""), h[1]))) + ",\n"
            continue
# 替换最后一个逗号为分号
workdays_sql = workdays_sql[:-2] + ";"
with open("./workdays_value.sql", "w", encoding="utf-8") as f:
    f.write(workdays_sql)
    print("workdays_sql写入文件workdays_value.sql成功!")

节假日sql数据

节假日表【holidays】创建语句:

CREATE TABLE `holidays` (
  `holiday` varchar(100) NOT NULL,
  `english_name` varchar(100) NOT NULL,
  `chinese_name` varchar(100) NOT NULL,
  PRIMARY KEY (`holiday`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

节假日数据sql语句:

insert into holidays(holiday,english_name,chinese_name) values ('2004-01-01', 'New Years Day', '元旦'),
('2004-01-22', 'Spring Festival', '春节'),
('2004-01-23', 'Spring Festival', '春节'),
('2004-01-24', 'Spring Festival', '春节'),
('2004-01-25', 'Spring Festival', '春节'),
('2004-01-26', 'Spring Festival', '春节'),
('2004-01-27', 'Spring Festival', '春节'),
('2004-01-28', 'Spring Festival', '春节'),
('2004-05-01', 'Labour Day', '劳动节'),
('2004-05-02', 'Labour Day', '劳动节'),
('2004-05-03', 'Labour Day', '劳动节'),
('2004-05-04', 'Labour Day', '劳动节'),
('2004-05-05', 'Labour Day', '劳动节'),
('2004-05-06', 'Labour Day', '劳动节'),
('2004-05-07', 'Labour Day', '劳动节'),
('2004-10-01', 'National Day', '国庆节'),
('2004-10-02', 'National Day', '国庆节'),
('2004-10-03', 'National Day', '国庆节'),
('2004-10-04', 'National Day', '国庆节'),
('2004-10-05', 'National Day', '国庆节'),
('2004-10-06', 'National Day', '国庆节'),
('2004-10-07', 'National Day', '国庆节'),
('2005-01-01', 'New Years Day', '元旦'),
('2005-01-02', 'New Years Day', '元旦'),
('2005-01-03', 'New Years Day', '元旦'),
('2005-02-09', 'Spring Festival', '春节'),
('2005-02-10', 'Spring Festival', '春节'),
('2005-02-11', 'Spring Festival', '春节'),
('2005-02-12', 'Spring Festival', '春节'),
('2005-02-13', 'Spring Festival', '春节'),
('2005-02-14', 'Spring Festival', '春节'),
('2005-02-15', 'Spring Festival', '春节'),
('2005-05-01', 'Labour Day', '劳动节'),
('2005-05-02', 'Labour Day', '劳动节'),
('2005-05-03', 'Labour Day', '劳动节'),
('2005-05-04', 'Labour Day', '劳动节'),
('2005-05-05', 'Labour Day', '劳动节'),
('2005-05-06', 'Labour Day', '劳动节'),
('2005-05-07', 'Labour Day', '劳动节'),
('2005-10-01', 'National Day', '国庆节'),
('2005-10-02', 'National Day', '国庆节'),
('2005-10-03', 'National Day', '国庆节'),
('2005-10-04', 'National Day', '国庆节'),
('2005-10-05', 'National Day', '国庆节'),
('2005-10-06', 'National Day', '国庆节'),
('2005-10-07', 'National Day', '国庆节'),
('2006-01-01', 'New Years Day', '元旦'),
('2006-01-02', 'New Years Day', '元旦'),
('2006-01-03', 'New Years Day', '元旦'),
('2006-01-29', 'Spring Festival', '春节'),
('2006-01-30', 'Spring Festival', '春节'),
('2006-01-31', 'Spring Festival', '春节'),
('2006-02-01', 'Spring Festival', '春节'),
('2006-02-02', 'Spring Festival', '春节'),
('2006-02-03', 'Spring Festival', '春节'),
('2006-02-04', 'Spring Festival', '春节'),
('2006-05-01', 'Labour Day', '劳动节'),
('2006-05-02', 'Labour Day', '劳动节'),
('2006-05-03', 'Labour Day', '劳动节'),
('2006-05-04', 'Labour Day', '劳动节'),
('2006-05-05', 'Labour Day', '劳动节'),
('2006-05-06', 'Labour Day', '劳动节'),
('2006-05-07', 'Labour Day', '劳动节'),
('2006-10-01', 'National Day', '国庆节'),
('2006-10-02', 'National Day', '国庆节'),
('2006-10-03', 'National Day', '国庆节'),
('2006-10-04', 'National Day', '国庆节'),
('2006-10-05', 'National Day', '国庆节'),
('2006-10-06', 'National Day', '国庆节'),
('2006-10-07', 'National Day', '国庆节'),
('2007-01-01', 'New Years Day', '元旦'),
('2007-01-02', 'New Years Day', '元旦'),
('2007-01-03', 'New Years Day', '元旦'),
('2007-02-18', 'Spring Festival', '春节'),
('2007-02-19', 'Spring Festival', '春节'),
('2007-02-20', 'Spring Festival', '春节'),
('2007-02-21', 'Spring Festival', '春节'),
('2007-02-22', 'Spring Festival', '春节'),
('2007-02-23', 'Spring Festival', '春节'),
('2007-02-24', 'Spring Festival', '春节'),
('2007-05-01', 'Labour Day', '劳动节'),
('2007-05-02', 'Labour Day', '劳动节'),
('2007-05-03', 'Labour Day', '劳动节'),
('2007-05-04', 'Labour Day', '劳动节'),
('2007-05-05', 'Labour Day', '劳动节'),
('2007-05-06', 'Labour Day', '劳动节'),
('2007-05-07', 'Labour Day', '劳动节'),
('2007-10-01', 'National Day', '国庆节'),
('2007-10-02', 'National Day', '国庆节'),
('2007-10-03', 'National Day', '国庆节'),
('2007-10-04', 'National Day', '国庆节'),
('2007-10-05', 'National Day', '国庆节'),
('2007-10-06', 'National Day', '国庆节'),
('2007-10-07', 'National Day', '国庆节'),
('2007-12-30', 'New Years Day', '元旦'),
('2007-12-31', 'New Years Day', '元旦'),
('2008-01-01', 'New Years Day', '元旦'),
('2008-02-06', 'Spring Festival', '春节'),
('2008-02-07', 'Spring Festival', '春节'),
('2008-02-08', 'Spring Festival', '春节'),
('2008-02-09', 'Spring Festival', '春节'),
('2008-02-10', 'Spring Festival', '春节'),
('2008-02-11', 'Spring Festival', '春节'),
('2008-02-12', 'Spring Festival', '春节'),
('2008-04-04', 'Tomb-sweeping Day', '清明'),
('2008-04-05', 'Tomb-sweeping Day', '清明'),
('2008-04-06', 'Tomb-sweeping Day', '清明'),
('2008-05-01', 'Labour Day', '劳动节'),
('2008-05-02', 'Labour Day', '劳动节'),
('2008-05-03', 'Labour Day', '劳动节'),
('2008-06-07', 'Dragon Boat Festival', '端午'),
('2008-06-08', 'Dragon Boat Festival', '端午'),
('2008-06-09', 'Dragon Boat Festival', '端午'),
('2008-09-13', 'Mid-autumn Festival', '中秋'),
('2008-09-14', 'Mid-autumn Festival', '中秋'),
('2008-09-15', 'Mid-autumn Festival', '中秋'),
('2008-09-29', 'National Day', '国庆节'),
('2008-09-30', 'National Day', '国庆节'),
('2008-10-01', 'National Day', '国庆节'),
('2008-10-02', 'National Day', '国庆节'),
('2008-10-03', 'National Day', '国庆节'),
('2008-10-04', 'National Day', '国庆节'),
('2008-10-05', 'National Day', '国庆节'),
('2009-01-01', 'New Years Day', '元旦'),
('2009-01-02', 'New Years Day', '元旦'),
('2009-01-03', 'New Years Day', '元旦'),
('2009-01-25', 'Spring Festival', '春节'),
('2009-01-26', 'Spring Festival', '春节'),
('2009-01-27', 'Spring Festival', '春节'),
('2009-01-28', 'Spring Festival', '春节'),
('2009-01-29', 'Spring Festival', '春节'),
('2009-01-30', 'Spring Festival', '春节'),
('2009-01-31', 'Spring Festival', '春节'),
('2009-04-04', 'Tomb-sweeping Day', '清明'),
('2009-04-05', 'Tomb-sweeping Day', '清明'),
('2009-04-06', 'Tomb-sweeping Day', '清明'),
('2009-05-01', 'Labour Day', '劳动节'),
('2009-05-02', 'Labour Day', '劳动节'),
('2009-05-03', 'Labour Day', '劳动节'),
('2009-05-28', 'Dragon Boat Festival', '端午'),
('2009-05-29', 'Dragon Boat Festival', '端午'),
('2009-05-30', 'Dragon Boat Festival', '端午'),
('2009-10-01', 'National Day', '国庆节'),
('2009-10-02', 'National Day', '国庆节'),
('2009-10-03', 'Mid-autumn Festival', '中秋'),
('2009-10-04', 'National Day', '国庆节'),
('2009-10-05', 'National Day', '国庆节'),
('2009-10-06', 'National Day', '国庆节'),
('2009-10-07', 'National Day', '国庆节'),
('2009-10-08', 'National Day', '国庆节'),
('2010-01-01', 'New Years Day', '元旦'),
('2010-01-02', 'New Years Day', '元旦'),
('2010-01-03', 'New Years Day', '元旦'),
('2010-02-13', 'Spring Festival', '春节'),
('2010-02-14', 'Spring Festival', '春节'),
('2010-02-15', 'Spring Festival', '春节'),
('2010-02-16', 'Spring Festival', '春节'),
('2010-02-17', 'Spring Festival', '春节'),
('2010-02-18', 'Spring Festival', '春节'),
('2010-02-19', 'Spring Festival', '春节'),
('2010-04-03', 'Tomb-sweeping Day', '清明'),
('2010-04-04', 'Tomb-sweeping Day', '清明'),
('2010-04-05', 'Tomb-sweeping Day', '清明'),
('2010-05-01', 'Labour Day', '劳动节'),
('2010-05-02', 'Labour Day', '劳动节'),
('2010-05-03', 'Labour Day', '劳动节'),
('2010-06-14', 'Dragon Boat Festival', '端午'),
('2010-06-15', 'Dragon Boat Festival', '端午'),
('2010-06-16', 'Dragon Boat Festival', '端午'),
('2010-09-22', 'Mid-autumn Festival', '中秋'),
('2010-09-23', 'Mid-autumn Festival', '中秋'),
('2010-09-24', 'Mid-autumn Festival', '中秋'),
('2010-10-01', 'National Day', '国庆节'),
('2010-10-02', 'National Day', '国庆节'),
('2010-10-03', 'National Day', '国庆节'),
('2010-10-04', 'National Day', '国庆节'),
('2010-10-05', 'National Day', '国庆节'),
('2010-10-06', 'National Day', '国庆节'),
('2010-10-07', 'National Day', '国庆节'),
('2011-01-01', 'New Years Day', '元旦'),
('2011-01-02', 'New Years Day', '元旦'),
('2011-01-03', 'New Years Day', '元旦'),
('2011-02-02', 'Spring Festival', '春节'),
('2011-02-03', 'Spring Festival', '春节'),
('2011-02-04', 'Spring Festival', '春节'),
('2011-02-05', 'Spring Festival', '春节'),
('2011-02-06', 'Spring Festival', '春节'),
('2011-02-07', 'Spring Festival', '春节'),
('2011-02-08', 'Spring Festival', '春节'),
('2011-04-03', 'Tomb-sweeping Day', '清明'),
('2011-04-04', 'Tomb-sweeping Day', '清明'),
('2011-04-05', 'Tomb-sweeping Day', '清明'),
('2011-04-30', 'Labour Day', '劳动节'),
('2011-05-01', 'Labour Day', '劳动节'),
('2011-05-02', 'Labour Day', '劳动节'),
('2011-06-04', 'Dragon Boat Festival', '端午'),
('2011-06-06', 'Dragon Boat Festival', '端午'),
('2011-09-10', 'Mid-autumn Festival', '中秋'),
('2011-09-11', 'Mid-autumn Festival', '中秋'),
('2011-09-12', 'Mid-autumn Festival', '中秋'),
('2011-10-01', 'National Day', '国庆节'),
('2011-10-02', 'National Day', '国庆节'),
('2011-10-03', 'National Day', '国庆节'),
('2011-10-04', 'National Day', '国庆节'),
('2011-10-05', 'National Day', '国庆节'),
('2011-10-06', 'National Day', '国庆节'),
('2011-10-07', 'National Day', '国庆节'),
('2012-01-01', 'New Years Day', '元旦'),
('2012-01-02', 'New Years Day', '元旦'),
('2012-01-03', 'New Years Day', '元旦'),
('2012-01-22', 'Spring Festival', '春节'),
('2012-01-23', 'Spring Festival', '春节'),
('2012-01-24', 'Spring Festival', '春节'),
('2012-01-25', 'Spring Festival', '春节'),
('2012-01-26', 'Spring Festival', '春节'),
('2012-01-27', 'Spring Festival', '春节'),
('2012-01-28', 'Spring Festival', '春节'),
('2012-04-02', 'Tomb-sweeping Day', '清明'),
('2012-04-03', 'Tomb-sweeping Day', '清明'),
('2012-04-04', 'Tomb-sweeping Day', '清明'),
('2012-04-29', 'Labour Day', '劳动节'),
('2012-04-30', 'Labour Day', '劳动节'),
('2012-05-01', 'Labour Day', '劳动节'),
('2012-06-22', 'Dragon Boat Festival', '端午'),
('2012-06-24', 'Dragon Boat Festival', '端午'),
('2012-09-30', 'Mid-autumn Festival', '中秋'),
('2012-10-01', 'National Day', '国庆节'),
('2012-10-02', 'National Day', '国庆节'),
('2012-10-03', 'National Day', '国庆节'),
('2012-10-04', 'National Day', '国庆节'),
('2012-10-05', 'National Day', '国庆节'),
('2012-10-06', 'National Day', '国庆节'),
('2012-10-07', 'National Day', '国庆节'),
('2013-01-01', 'New Years Day', '元旦'),
('2013-01-02', 'New Years Day', '元旦'),
('2013-01-03', 'New Years Day', '元旦'),
('2013-02-09', 'Spring Festival', '春节'),
('2013-02-10', 'Spring Festival', '春节'),
('2013-02-11', 'Spring Festival', '春节'),
('2013-02-12', 'Spring Festival', '春节'),
('2013-02-13', 'Spring Festival', '春节'),
('2013-02-14', 'Spring Festival', '春节'),
('2013-02-15', 'Spring Festival', '春节'),
('2013-04-04', 'Tomb-sweeping Day', '清明'),
('2013-04-05', 'Tomb-sweeping Day', '清明'),
('2013-04-06', 'Tomb-sweeping Day', '清明'),
('2013-04-29', 'Labour Day', '劳动节'),
('2013-04-30', 'Labour Day', '劳动节'),
('2013-05-01', 'Labour Day', '劳动节'),
('2013-06-10', 'Dragon Boat Festival', '端午'),
('2013-06-11', 'Dragon Boat Festival', '端午'),
('2013-06-12', 'Dragon Boat Festival', '端午'),
('2013-09-19', 'Mid-autumn Festival', '中秋'),
('2013-09-20', 'Mid-autumn Festival', '中秋'),
('2013-09-21', 'Mid-autumn Festival', '中秋'),
('2013-10-01', 'National Day', '国庆节'),
('2013-10-02', 'National Day', '国庆节'),
('2013-10-03', 'National Day', '国庆节'),
('2013-10-04', 'National Day', '国庆节'),
('2013-10-05', 'National Day', '国庆节'),
('2013-10-06', 'National Day', '国庆节'),
('2013-10-07', 'National Day', '国庆节'),
('2014-01-01', 'New Years Day', '元旦'),
('2014-01-31', 'Spring Festival', '春节'),
('2014-02-01', 'Spring Festival', '春节'),
('2014-02-02', 'Spring Festival', '春节'),
('2014-02-03', 'Spring Festival', '春节'),
('2014-02-04', 'Spring Festival', '春节'),
('2014-02-05', 'Spring Festival', '春节'),
('2014-02-06', 'Spring Festival', '春节'),
('2014-04-05', 'Tomb-sweeping Day', '清明'),
('2014-04-06', 'Tomb-sweeping Day', '清明'),
('2014-04-07', 'Tomb-sweeping Day', '清明'),
('2014-05-01', 'Labour Day', '劳动节'),
('2014-05-02', 'Labour Day', '劳动节'),
('2014-05-03', 'Labour Day', '劳动节'),
('2014-06-02', 'Dragon Boat Festival', '端午'),
('2014-09-08', 'Mid-autumn Festival', '中秋'),
('2014-10-01', 'National Day', '国庆节'),
('2014-10-02', 'National Day', '国庆节'),
('2014-10-03', 'National Day', '国庆节'),
('2014-10-04', 'National Day', '国庆节'),
('2014-10-05', 'National Day', '国庆节'),
('2014-10-06', 'National Day', '国庆节'),
('2014-10-07', 'National Day', '国庆节'),
('2015-01-01', 'New Years Day', '元旦'),
('2015-01-02', 'New Years Day', '元旦'),
('2015-01-03', 'New Years Day', '元旦'),
('2015-02-18', 'Spring Festival', '春节'),
('2015-02-19', 'Spring Festival', '春节'),
('2015-02-20', 'Spring Festival', '春节'),
('2015-02-21', 'Spring Festival', '春节'),
('2015-02-22', 'Spring Festival', '春节'),
('2015-02-23', 'Spring Festival', '春节'),
('2015-02-24', 'Spring Festival', '春节'),
('2015-04-05', 'Tomb-sweeping Day', '清明'),
('2015-04-06', 'Tomb-sweeping Day', '清明'),
('2015-05-01', 'Labour Day', '劳动节'),
('2015-06-20', 'Dragon Boat Festival', '端午'),
('2015-06-22', 'Dragon Boat Festival', '端午'),
('2015-09-27', 'Mid-autumn Festival', '中秋'),
('2015-10-01', 'National Day', '国庆节'),
('2015-10-02', 'National Day', '国庆节'),
('2015-10-03', 'National Day', '国庆节'),
('2015-10-04', 'National Day', '国庆节'),
('2015-10-05', 'National Day', '国庆节'),
('2015-10-06', 'National Day', '国庆节'),
('2015-10-07', 'National Day', '国庆节'),
('2016-01-01', 'New Years Day', '元旦'),
('2016-02-07', 'Spring Festival', '春节'),
('2016-02-08', 'Spring Festival', '春节'),
('2016-02-09', 'Spring Festival', '春节'),
('2016-02-10', 'Spring Festival', '春节'),
('2016-02-11', 'Spring Festival', '春节'),
('2016-02-12', 'Spring Festival', '春节'),
('2016-02-13', 'Spring Festival', '春节'),
('2016-04-04', 'Tomb-sweeping Day', '清明'),
('2016-05-01', 'Labour Day', '劳动节'),
('2016-05-02', 'Labour Day', '劳动节'),
('2016-06-09', 'Dragon Boat Festival', '端午'),
('2016-06-10', 'Dragon Boat Festival', '端午'),
('2016-06-11', 'Dragon Boat Festival', '端午'),
('2016-09-15', 'Mid-autumn Festival', '中秋'),
('2016-09-16', 'Mid-autumn Festival', '中秋'),
('2016-09-17', 'Mid-autumn Festival', '中秋'),
('2016-10-01', 'National Day', '国庆节'),
('2016-10-02', 'National Day', '国庆节'),
('2016-10-03', 'National Day', '国庆节'),
('2016-10-04', 'National Day', '国庆节'),
('2016-10-05', 'National Day', '国庆节'),
('2016-10-06', 'National Day', '国庆节'),
('2016-10-07', 'National Day', '国庆节'),
('2017-01-01', 'New Years Day', '元旦'),
('2017-01-02', 'New Years Day', '元旦'),
('2017-01-27', 'Spring Festival', '春节'),
('2017-01-28', 'Spring Festival', '春节'),
('2017-01-29', 'Spring Festival', '春节'),
('2017-01-30', 'Spring Festival', '春节'),
('2017-01-31', 'Spring Festival', '春节'),
('2017-02-01', 'Spring Festival', '春节'),
('2017-02-02', 'Spring Festival', '春节'),
('2017-04-02', 'Tomb-sweeping Day', '清明'),
('2017-04-03', 'Tomb-sweeping Day', '清明'),
('2017-04-04', 'Tomb-sweeping Day', '清明'),
('2017-05-01', 'Labour Day', '劳动节'),
('2017-05-28', 'Dragon Boat Festival', '端午'),
('2017-05-29', 'Dragon Boat Festival', '端午'),
('2017-05-30', 'Dragon Boat Festival', '端午'),
('2017-10-01', 'National Day', '国庆节'),
('2017-10-02', 'National Day', '国庆节'),
('2017-10-03', 'National Day', '国庆节'),
('2017-10-04', 'Mid-autumn Festival', '中秋'),
('2017-10-05', 'National Day', '国庆节'),
('2017-10-06', 'National Day', '国庆节'),
('2017-10-07', 'National Day', '国庆节'),
('2017-10-08', 'National Day', '国庆节'),
('2018-01-01', 'New Years Day', '元旦'),
('2018-02-15', 'Spring Festival', '春节'),
('2018-02-16', 'Spring Festival', '春节'),
('2018-02-17', 'Spring Festival', '春节'),
('2018-02-18', 'Spring Festival', '春节'),
('2018-02-19', 'Spring Festival', '春节'),
('2018-02-20', 'Spring Festival', '春节'),
('2018-02-21', 'Spring Festival', '春节'),
('2018-04-05', 'Tomb-sweeping Day', '清明'),
('2018-04-06', 'Tomb-sweeping Day', '清明'),
('2018-04-07', 'Tomb-sweeping Day', '清明'),
('2018-04-29', 'Labour Day', '劳动节'),
('2018-04-30', 'Labour Day', '劳动节'),
('2018-05-01', 'Labour Day', '劳动节'),
('2018-06-18', 'Dragon Boat Festival', '端午'),
('2018-09-24', 'Mid-autumn Festival', '中秋'),
('2018-10-01', 'National Day', '国庆节'),
('2018-10-02', 'National Day', '国庆节'),
('2018-10-03', 'National Day', '国庆节'),
('2018-10-04', 'National Day', '国庆节'),
('2018-10-05', 'National Day', '国庆节'),
('2018-10-06', 'National Day', '国庆节'),
('2018-10-07', 'National Day', '国庆节'),
('2018-12-30', 'New Years Day', '元旦'),
('2018-12-31', 'New Years Day', '元旦'),
('2019-01-01', 'New Years Day', '元旦'),
('2019-02-04', 'Spring Festival', '春节'),
('2019-02-05', 'Spring Festival', '春节'),
('2019-02-06', 'Spring Festival', '春节'),
('2019-02-07', 'Spring Festival', '春节'),
('2019-02-08', 'Spring Festival', '春节'),
('2019-02-09', 'Spring Festival', '春节'),
('2019-02-10', 'Spring Festival', '春节'),
('2019-04-05', 'Tomb-sweeping Day', '清明'),
('2019-04-06', 'Tomb-sweeping Day', '清明'),
('2019-04-07', 'Tomb-sweeping Day', '清明'),
('2019-05-01', 'Labour Day', '劳动节'),
('2019-05-02', 'Labour Day', '劳动节'),
('2019-05-03', 'Labour Day', '劳动节'),
('2019-05-04', 'Labour Day', '劳动节'),
('2019-06-07', 'Dragon Boat Festival', '端午'),
('2019-06-08', 'Dragon Boat Festival', '端午'),
('2019-06-09', 'Dragon Boat Festival', '端午'),
('2019-09-13', 'Mid-autumn Festival', '中秋'),
('2019-09-14', 'Mid-autumn Festival', '中秋'),
('2019-09-15', 'Mid-autumn Festival', '中秋'),
('2019-10-01', 'National Day', '国庆节'),
('2019-10-02', 'National Day', '国庆节'),
('2019-10-03', 'National Day', '国庆节'),
('2019-10-04', 'National Day', '国庆节'),
('2019-10-05', 'National Day', '国庆节'),
('2019-10-06', 'National Day', '国庆节'),
('2019-10-07', 'National Day', '国庆节'),
('2020-01-01', 'New Years Day', '元旦'),
('2020-01-24', 'Spring Festival', '春节'),
('2020-01-25', 'Spring Festival', '春节'),
('2020-01-26', 'Spring Festival', '春节'),
('2020-01-27', 'Spring Festival', '春节'),
('2020-01-28', 'Spring Festival', '春节'),
('2020-01-29', 'Spring Festival', '春节'),
('2020-01-30', 'Spring Festival', '春节'),
('2020-01-31', 'Spring Festival', '春节'),
('2020-02-01', 'Spring Festival', '春节'),
('2020-02-02', 'Spring Festival', '春节'),
('2020-04-04', 'Tomb-sweeping Day', '清明'),
('2020-04-05', 'Tomb-sweeping Day', '清明'),
('2020-04-06', 'Tomb-sweeping Day', '清明'),
('2020-05-01', 'Labour Day', '劳动节'),
('2020-05-02', 'Labour Day', '劳动节'),
('2020-05-03', 'Labour Day', '劳动节'),
('2020-05-04', 'Labour Day', '劳动节'),
('2020-05-05', 'Labour Day', '劳动节'),
('2020-06-25', 'Dragon Boat Festival', '端午'),
('2020-06-26', 'Dragon Boat Festival', '端午'),
('2020-06-27', 'Dragon Boat Festival', '端午'),
('2020-10-01', 'National Day', '国庆节'),
('2020-10-02', 'National Day', '国庆节'),
('2020-10-03', 'National Day', '国庆节'),
('2020-10-04', 'National Day', '国庆节'),
('2020-10-05', 'National Day', '国庆节'),
('2020-10-06', 'National Day', '国庆节'),
('2020-10-07', 'National Day', '国庆节'),
('2020-10-08', 'National Day', '国庆节'),
('2021-01-01', 'New Years Day', '元旦'),
('2021-01-02', 'New Years Day', '元旦'),
('2021-01-03', 'New Years Day', '元旦'),
('2021-02-11', 'Spring Festival', '春节'),
('2021-02-12', 'Spring Festival', '春节'),
('2021-02-13', 'Spring Festival', '春节'),
('2021-02-14', 'Spring Festival', '春节'),
('2021-02-15', 'Spring Festival', '春节'),
('2021-02-16', 'Spring Festival', '春节'),
('2021-02-17', 'Spring Festival', '春节'),
('2021-04-03', 'Tomb-sweeping Day', '清明'),
('2021-04-04', 'Tomb-sweeping Day', '清明'),
('2021-04-05', 'Tomb-sweeping Day', '清明'),
('2021-05-01', 'Labour Day', '劳动节'),
('2021-05-02', 'Labour Day', '劳动节'),
('2021-05-03', 'Labour Day', '劳动节'),
('2021-05-04', 'Labour Day', '劳动节'),
('2021-05-05', 'Labour Day', '劳动节'),
('2021-06-12', 'Dragon Boat Festival', '端午'),
('2021-06-13', 'Dragon Boat Festival', '端午'),
('2021-06-14', 'Dragon Boat Festival', '端午'),
('2021-09-19', 'Mid-autumn Festival', '中秋'),
('2021-09-20', 'Mid-autumn Festival', '中秋'),
('2021-09-21', 'Mid-autumn Festival', '中秋'),
('2021-10-01', 'National Day', '国庆节'),
('2021-10-02', 'National Day', '国庆节'),
('2021-10-03', 'National Day', '国庆节'),
('2021-10-04', 'National Day', '国庆节'),
('2021-10-05', 'National Day', '国庆节'),
('2021-10-06', 'National Day', '国庆节'),
('2021-10-07', 'National Day', '国庆节'),
('2022-01-01', 'New Years Day', '元旦'),
('2022-01-02', 'New Years Day', '元旦'),
('2022-01-03', 'New Years Day', '元旦'),
('2022-01-31', 'Spring Festival', '春节'),
('2022-02-01', 'Spring Festival', '春节'),
('2022-02-02', 'Spring Festival', '春节'),
('2022-02-03', 'Spring Festival', '春节'),
('2022-02-04', 'Spring Festival', '春节'),
('2022-02-05', 'Spring Festival', '春节'),
('2022-02-06', 'Spring Festival', '春节'),
('2022-04-03', 'Tomb-sweeping Day', '清明'),
('2022-04-04', 'Tomb-sweeping Day', '清明'),
('2022-04-05', 'Tomb-sweeping Day', '清明'),
('2022-04-30', 'Labour Day', '劳动节'),
('2022-05-01', 'Labour Day', '劳动节'),
('2022-05-02', 'Labour Day', '劳动节'),
('2022-05-03', 'Labour Day', '劳动节'),
('2022-05-04', 'Labour Day', '劳动节'),
('2022-06-03', 'Dragon Boat Festival', '端午'),
('2022-06-04', 'Dragon Boat Festival', '端午'),
('2022-06-05', 'Dragon Boat Festival', '端午'),
('2022-09-10', 'Mid-autumn Festival', '中秋'),
('2022-09-11', 'Mid-autumn Festival', '中秋'),
('2022-09-12', 'Mid-autumn Festival', '中秋'),
('2022-10-01', 'National Day', '国庆节'),
('2022-10-02', 'National Day', '国庆节'),
('2022-10-03', 'National Day', '国庆节'),
('2022-10-04', 'National Day', '国庆节'),
('2022-10-05', 'National Day', '国庆节'),
('2022-10-06', 'National Day', '国庆节'),
('2022-10-07', 'National Day', '国庆节'),
('2022-12-31', 'New Years Day', '元旦'),
('2023-01-01', 'New Years Day', '元旦'),
('2023-01-02', 'New Years Day', '元旦'),
('2023-01-21', 'Spring Festival', '春节'),
('2023-01-22', 'Spring Festival', '春节'),
('2023-01-23', 'Spring Festival', '春节'),
('2023-01-24', 'Spring Festival', '春节'),
('2023-01-25', 'Spring Festival', '春节'),
('2023-01-26', 'Spring Festival', '春节'),
('2023-01-27', 'Spring Festival', '春节'),
('2023-04-05', 'Tomb-sweeping Day', '清明'),
('2023-04-29', 'Labour Day', '劳动节'),
('2023-04-30', 'Labour Day', '劳动节'),
('2023-05-01', 'Labour Day', '劳动节'),
('2023-05-02', 'Labour Day', '劳动节'),
('2023-05-03', 'Labour Day', '劳动节'),
('2023-06-22', 'Dragon Boat Festival', '端午'),
('2023-06-23', 'Dragon Boat Festival', '端午'),
('2023-06-24', 'Dragon Boat Festival', '端午'),
('2023-09-29', 'Mid-autumn Festival', '中秋'),
('2023-09-30', 'National Day', '国庆节'),
('2023-10-01', 'National Day', '国庆节'),
('2023-10-02', 'National Day', '国庆节'),
('2023-10-03', 'National Day', '国庆节'),
('2023-10-04', 'National Day', '国庆节'),
('2023-10-05', 'National Day', '国庆节'),
('2023-10-06', 'National Day', '国庆节'),
('2024-01-01', 'New Years Day', '元旦'),
('2024-02-10', 'Spring Festival', '春节'),
('2024-02-11', 'Spring Festival', '春节'),
('2024-02-12', 'Spring Festival', '春节'),
('2024-02-13', 'Spring Festival', '春节'),
('2024-02-14', 'Spring Festival', '春节'),
('2024-02-15', 'Spring Festival', '春节'),
('2024-02-16', 'Spring Festival', '春节'),
('2024-02-17', 'Spring Festival', '春节'),
('2024-04-04', 'Tomb-sweeping Day', '清明'),
('2024-04-05', 'Tomb-sweeping Day', '清明'),
('2024-04-06', 'Tomb-sweeping Day', '清明'),
('2024-05-01', 'Labour Day', '劳动节'),
('2024-05-02', 'Labour Day', '劳动节'),
('2024-05-03', 'Labour Day', '劳动节'),
('2024-05-04', 'Labour Day', '劳动节'),
('2024-05-05', 'Labour Day', '劳动节'),
('2024-06-10', 'Dragon Boat Festival', '端午'),
('2024-09-15', 'Mid-autumn Festival', '中秋'),
('2024-09-16', 'Mid-autumn Festival', '中秋'),
('2024-09-17', 'Mid-autumn Festival', '中秋'),
('2024-10-01', 'National Day', '国庆节'),
('2024-10-02', 'National Day', '国庆节'),
('2024-10-03', 'National Day', '国庆节'),
('2024-10-04', 'National Day', '国庆节'),
('2024-10-05', 'National Day', '国庆节'),
('2024-10-06', 'National Day', '国庆节'),
('2024-10-07', 'National Day', '国庆节');

调休日sql数据

调休日表【weekdays】创建语句:

CREATE TABLE `workdays` (
  `workday` varchar(100) NOT NULL,
  `english_name` varchar(100) NOT NULL,
  `chinese_name` varchar(100) NOT NULL,
  PRIMARY KEY (`workday`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

调休日sql语句:

insert into workdays(workday,english_name,chinese_name) values ('2004-01-17', 'Spring Festival', '春节'),
('2004-01-18', 'Spring Festival', '春节'),
('2004-05-08', 'Labour Day', '劳动节'),
('2004-05-09', 'Labour Day', '劳动节'),
('2004-10-09', 'National Day', '国庆节'),
('2004-10-10', 'National Day', '国庆节'),
('2005-02-05', 'Spring Festival', '春节'),
('2005-02-06', 'Spring Festival', '春节'),
('2005-04-30', 'Labour Day', '劳动节'),
('2005-05-08', 'Labour Day', '劳动节'),
('2005-10-08', 'National Day', '国庆节'),
('2005-10-09', 'National Day', '国庆节'),
('2006-01-28', 'Spring Festival', '春节'),
('2006-02-05', 'Spring Festival', '春节'),
('2006-04-29', 'Labour Day', '劳动节'),
('2006-04-30', 'Labour Day', '劳动节'),
('2006-09-30', 'National Day', '国庆节'),
('2006-10-08', 'National Day', '国庆节'),
('2006-12-30', 'New Years Day', '元旦'),
('2006-12-31', 'New Years Day', '元旦'),
('2007-02-17', 'Spring Festival', '春节'),
('2007-02-25', 'Spring Festival', '春节'),
('2007-04-28', 'Labour Day', '劳动节'),
('2007-04-29', 'Labour Day', '劳动节'),
('2007-09-29', 'National Day', '国庆节'),
('2007-09-30', 'National Day', '国庆节'),
('2007-12-29', 'New Years Day', '元旦'),
('2008-02-02', 'Spring Festival', '春节'),
('2008-02-03', 'Spring Festival', '春节'),
('2008-05-04', 'Labour Day', '劳动节'),
('2008-09-27', 'National Day', '国庆节'),
('2008-09-28', 'National Day', '国庆节'),
('2009-01-04', 'New Years Day', '元旦'),
('2009-01-24', 'Spring Festival', '春节'),
('2009-02-01', 'Spring Festival', '春节'),
('2009-05-31', 'Dragon Boat Festival', '端午'),
('2009-09-27', 'National Day', '国庆节'),
('2009-10-10', 'National Day', '国庆节'),
('2010-02-20', 'Spring Festival', '春节'),
('2010-02-21', 'Spring Festival', '春节'),
('2010-06-12', 'Dragon Boat Festival', '端午'),
('2010-06-13', 'Dragon Boat Festival', '端午'),
('2010-09-19', 'Mid-autumn Festival', '中秋'),
('2010-09-25', 'Mid-autumn Festival', '中秋'),
('2010-09-26', 'National Day', '国庆节'),
('2010-10-09', 'National Day', '国庆节'),
('2011-01-30', 'Spring Festival', '春节'),
('2011-02-12', 'Spring Festival', '春节'),
('2011-04-02', 'Tomb-sweeping Day', '清明'),
('2011-10-08', 'National Day', '国庆节'),
('2011-10-09', 'National Day', '国庆节'),
('2011-12-31', 'New Years Day', '元旦'),
('2012-01-21', 'Spring Festival', '春节'),
('2012-01-29', 'Spring Festival', '春节'),
('2012-03-31', 'Tomb-sweeping Day', '清明'),
('2012-04-01', 'Tomb-sweeping Day', '清明'),
('2012-04-28', 'Labour Day', '劳动节'),
('2012-09-29', 'National Day', '国庆节'),
('2013-01-05', 'New Years Day', '元旦'),
('2013-01-06', 'New Years Day', '元旦'),
('2013-02-16', 'Spring Festival', '春节'),
('2013-02-17', 'Spring Festival', '春节'),
('2013-04-07', 'Tomb-sweeping Day', '清明'),
('2013-04-27', 'Labour Day', '劳动节'),
('2013-04-28', 'Labour Day', '劳动节'),
('2013-06-08', 'Dragon Boat Festival', '端午'),
('2013-06-09', 'Dragon Boat Festival', '端午'),
('2013-09-22', 'Mid-autumn Festival', '中秋'),
('2013-09-29', 'National Day', '国庆节'),
('2013-10-12', 'National Day', '国庆节'),
('2014-01-26', 'Spring Festival', '春节'),
('2014-02-08', 'Spring Festival', '春节'),
('2014-05-04', 'Labour Day', '劳动节'),
('2014-09-28', 'National Day', '国庆节'),
('2014-10-11', 'National Day', '国庆节'),
('2015-01-04', 'New Years Day', '元旦'),
('2015-02-15', 'Spring Festival', '春节'),
('2015-02-28', 'Spring Festival', '春节'),
('2015-10-10', 'National Day', '国庆节'),
('2016-02-06', 'Spring Festival', '春节'),
('2016-02-14', 'Spring Festival', '春节'),
('2016-06-12', 'Dragon Boat Festival', '端午'),
('2016-09-18', 'Mid-autumn Festival', '中秋'),
('2016-10-08', 'National Day', '国庆节'),
('2016-10-09', 'National Day', '国庆节'),
('2017-01-22', 'Spring Festival', '春节'),
('2017-02-04', 'Spring Festival', '春节'),
('2017-04-01', 'Tomb-sweeping Day', '清明'),
('2017-05-27', 'Dragon Boat Festival', '端午'),
('2017-09-30', 'National Day', '国庆节'),
('2018-02-11', 'Spring Festival', '春节'),
('2018-02-24', 'Spring Festival', '春节'),
('2018-04-08', 'Tomb-sweeping Day', '清明'),
('2018-04-28', 'Labour Day', '劳动节'),
('2018-09-29', 'National Day', '国庆节'),
('2018-09-30', 'National Day', '国庆节'),
('2018-12-29', 'New Years Day', '元旦'),
('2019-02-02', 'Spring Festival', '春节'),
('2019-02-03', 'Spring Festival', '春节'),
('2019-04-28', 'Labour Day', '劳动节'),
('2019-05-05', 'Labour Day', '劳动节'),
('2019-09-29', 'National Day', '国庆节'),
('2019-10-12', 'National Day', '国庆节'),
('2020-01-19', 'Spring Festival', '春节'),
('2020-04-26', 'Labour Day', '劳动节'),
('2020-05-09', 'Labour Day', '劳动节'),
('2020-06-28', 'Dragon Boat Festival', '端午'),
('2020-09-27', 'National Day', '国庆节'),
('2020-10-10', 'National Day', '国庆节'),
('2021-02-07', 'Spring Festival', '春节'),
('2021-02-20', 'Spring Festival', '春节'),
('2021-04-25', 'Labour Day', '劳动节'),
('2021-05-08', 'Labour Day', '劳动节'),
('2021-09-18', 'Mid-autumn Festival', '中秋'),
('2021-09-26', 'National Day', '国庆节'),
('2021-10-09', 'National Day', '国庆节'),
('2022-01-29', 'Spring Festival', '春节'),
('2022-01-30', 'Spring Festival', '春节'),
('2022-04-02', 'Tomb-sweeping Day', '清明'),
('2022-04-24', 'Labour Day', '劳动节'),
('2022-05-07', 'Labour Day', '劳动节'),
('2022-10-08', 'National Day', '国庆节'),
('2022-10-09', 'National Day', '国庆节'),
('2023-01-28', 'Spring Festival', '春节'),
('2023-01-29', 'Spring Festival', '春节'),
('2023-04-23', 'Labour Day', '劳动节'),
('2023-05-06', 'Labour Day', '劳动节'),
('2023-06-25', 'Dragon Boat Festival', '端午'),
('2023-10-07', 'National Day', '国庆节'),
('2023-10-08', 'National Day', '国庆节'),
('2024-02-04', 'Spring Festival', '春节'),
('2024-02-18', 'Spring Festival', '春节'),
('2024-04-07', 'Tomb-sweeping Day', '清明'),
('2024-04-28', 'Labour Day', '劳动节'),
('2024-05-11', 'Labour Day', '劳动节'),
('2024-09-14', 'Mid-autumn Festival', '中秋'),
('2024-09-29', 'National Day', '国庆节'),
('2024-10-12', 'National Day', '国庆节');

你可能感兴趣的:(python,sql,数据库,chinese,chinesecalendar)