gpt4 book ai didi

mysql 每年同一天

转载 作者:太空宇宙 更新时间:2023-11-03 11:39:23 25 4
gpt4 key购买 nike

我需要在 where 子句中使用 9 月 1 日,并且不想对年份进行硬编码。在 between 语句中返回 9/1/year 的最佳方法是什么?

where p.post_date between '2016-09-01' and DATE_ADD(CURDATE(),INTERVAL 1 DAY) 

正在寻找“2016-09-01”的替代品,以便它在明年和以后再次运行。此外,需要在同年的 10 月、11 月和 12 月工作。

最佳答案

您可以使用 month()day():

select t.*
from t
where month(datecol) = 9 and day(datecol) = 1;

关于mysql 每年同一天,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43187747/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com