仅使用月份和年份显示两个日期之间的数据 [英] Displaying data between two dates using the month and year only
本文介绍了仅使用月份和年份显示两个日期之间的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从mytable中选择*,其中MONTH(开始日期)和MONTH(结束日期)之间的MONTH(mydate)
如果我有上述声明并提供以下数据;
SN名称STARTINGDATE ENDINGDATE
1 BAB 2011年3月4日2012年5月7日
2 ggg 2011年4月16日10/03/2012
3 hhh 34/04/2011 16/04/2012
而我的mydate是05/04/2011
SN 2的数据将不包括在内,这不是假定的.
请帮我
select * from mytable where MONTH(mydate) BETWEEN MONTH(startingdate) and MONTH(endingdate)
If i have the above statement with the following data;
SN NAME STARTINGDATE ENDINGDATE
1 BAB 03/04/2011 05/07/2012
2 ggg 16/04/2011 10/03/2012
3 hhh 34/04/2011 16/04/2012
and my mydate is 05/04/2011
the data with SN 2 will not be included, which is not suppose to be.
Please kindly help me out
推荐答案
我不明白您的问题是什么.除了3个起始日期不正确的日期(没有第34天)之外,所有3个起始日期都在第4个月,如mydate
一样,因此所有结果都应包括在结果集中.
如果您要排除#2是因为它的起始日期DAY
在mydate
之后,则不要仅检查MONTH
,只需检查日期本身.
I don''t understand what your problem is. Besides 3 having a bad starting date (there''s no day 34) all 3 starting dates are in month 4, as ismydate
, so all should be included in the result set.
If you want #2 excluded because its starting dateDAY
is aftermydate
, then don''t check for just theMONTH
, just check the date itself.
是我们说没有机构可以找到解决这个问题的办法吗?这是我第三次发布此问题而没有解决方案.
我需要帮助
Are we saying there no body that can find solution to this problem? This is the third time I posted this problem without solution.
I NEED HELP BADLY
瓦尔特,谢谢.正确的数据是;
SN名称STARTINGDATE ENDINGDATE
1 BAB 2011年3月4日2012年5月7日
2 ggg 2011年4月16日10/03/2012
3 hhh 04/04/2011 16/04/2012
如果您搜索日期YEAR(MONTH(05/04/2011)),即搜索2011年4月,
仅显示数据1和3,不包括带有SN 2的数据,这不是假定的.所有应该显示的数据.
我需要帮助
Walt Thanks. The correct data is;
SN NAME STARTINGDATE ENDINGDATE
1 BAB 03/04/2011 05/07/2012
2 ggg 16/04/2011 10/03/2012
3 hhh 04/04/2011 16/04/2012
if u search for a date YEAR(MONTH(05/04/2011)), ie searching for April 2011,
only data 1 and 3 will display, the data with SN 2 will not be included, which is not suppose to be. All the data supposed to display.
I need help please
这篇关于仅使用月份和年份显示两个日期之间的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文