日期之间的SQL [英] SQL between dates
本文介绍了日期之间的SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试过
i.startdate between'2012-02-29'and i.enddate'2012-03-30'
但没有工作,我已经google了几个小时没有明确的答案,任何帮助将不胜感激,谢谢提前。
解决方案
如果我理解正确:
- 您的表格包含两个日期字段,
StartDate
和EndDate
,描述一个冗长的事件。 - 你想要找到所有完全落入的事件在另外两个日期描述的期间,在这种情况下,
2012-02-29
和2012-03-30
。 / li>
如果这是正确的,请使用:
SEL ECT * FROM Events
WHERE StartDate> ='2012-02-29'AND EndDate< ='2012-03-30';
I have table with two columns (startdate & enddate) and I have two submission dates (2012-02-29 & 2012-03-30) I am trying to get the data between startdate (2012-02-29) and the enddate (2012-03-30)
I've tried
i.startdate between '2012-02-29' and i.enddate '2012-03-30'
but that didnt work, I've been googling this for hours with no clear answer, any help would be appreciated, thanks in advance.
解决方案
If I understand correctly:
- Your table contains two date fields,
StartDate
andEndDate
, that describe a lengthy event. - You want to find all the events that fall completely within the period described by two other dates, in this case
2012-02-29
and2012-03-30
.
If this is correct then use this:
SELECT * FROM Events
WHERE StartDate >= '2012-02-29' AND EndDate <= '2012-03-30';
这篇关于日期之间的SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文