日期之间的日期,忽略年份 [英] Date between dates, ignore year
本文介绍了日期之间的日期,忽略年份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果日期在年份范围之外,则日期比较的最佳(最快)方法是什么?
What's the best (fastest) approach to compare if date is in range of dates independently from year?
表格日期":
some_column| since | upto |
-----------|--------------|-------------|
'foo' | '2011-05-01' | '2013-06-01'|
现在,我希望此查询返回"foo"
Now I want this query to return 'foo'
SELECT foo FROM dates WHERE '2014-05-05' BETWEEN `since` AND `upto`
如果需要,我可以更改日期"表中存储日期的类型/格式,但是我不能更改输入查询的日期格式,因为该值通常来自另一个表(这是使用联接的更复杂查询的一部分).
If needed, I can change type/format of stored dates in "dates" table, but I cannot change format of date which I put into query as that value is typically from another table (It's part of more complex query using joins).
推荐答案
使用 查看全文