gpt4 book ai didi

mysql - 搜索 mysql 两个包含单个日期的日期字段

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

我有一个表,其中包含日期时间格式的字段 start_date 和 end_date。

我需要做的是找到特定日期介于开始日期和结束日期之间的所有行。

例如,如果我的表中有这些行,我想获取开始到结束日期包括 2011-12-08 的所有行

start_date          end_date
2011-12-01 09:00:00 2011-12-04 17:00:00
2011-12-07 15:00:00 2011-12-09 16:00:00
2011-12-08 10:30:00 2011-12-08 14:00:00

实现此目标的最佳方法是什么?

最佳答案

select * from table
where '2011-12-08' between date(start_date) and date(end_date)

关于mysql - 搜索 mysql 两个包含单个日期的日期字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8430244/

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