如何查找两个日期的所有日期 [英] How to find all dates from two dates
本文介绍了如何查找两个日期的所有日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张有三个柱子的桌子..
I have a table which has three colums..
id | startdate | enddate
1 |'2014-01-02' |'2014-01-05'
如果我想查询一个日期为'2014-01-03',它应该取一个介于开始日期和结束日期之间的行...
请有人可以帮助我..提前致谢..
If suppose i query a date as '2014-01-03', it should fetch a rows which is in between the start date and end date...
Please anyone can help me.. Thanks in advance..
推荐答案
SELECT * FROM MyTable WHERE '2014-01-05' BETWEEN startdate AND enddate
请注意,只有在数据库中使用DATE或DATETIME列时才会起作用。如果您正在使用文本,请更改它们 - 这是一个非常糟糕的主意!
Note that is will only work when you are using DATE or DATETIME columns in your database. If you are using text, change them - it's a very poor idea!
尝试这种方式。
Try this way.
SELECT *
FROM table_1
WHERE '2014-01-03' between startdate
AND enddate
这篇关于如何查找两个日期的所有日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文