简体   繁体   English

如何使用mysql获取两个给定日期之间的日期列表?

[英]How can I get a list of dates between two given dates with mysql?

I need to generate a list of dates with MYSQl between two given dates and also, this list of the dates must to filter the dates that corresponds to Tuesday and Thursday days. 我需要使用两个给定日期之间的MYSQl生成日期列表,并且该日期列表还必须过滤对应于星期二和星期四的日期。 Is it possible? 可能吗?

In the meantime, here's a sample that you can use: 同时,您可以使用以下示例:

-- TO SELECT DATES IN A GIVEN RANGE
-- THAT DO NOT FALL ON A TUESDAY AND THURSDAY
SELECT dateColumn 
FROM yourTable 
WHERE DAYOFWEEK(dateColumn) NOT IN (3,5) 
    AND dateColumn BETWEEN '2011-01-01' and '2011-12-31';

If you want the dates enumerated (not from your database) then see this link: 如果要枚举日期(而不是数据库中的日期),请参见以下链接:

List of dates between two dates 两个日期之间的日期列表

You should be able to adjust the solution to filter for the desired day name using MySQL DayName function. 您应该能够使用MySQL DayName函数调整解决方案以过滤所需的日期名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM