如何在SQL Server中将(11/2011)与(02/2012)进行比较 [英] how to compare (11/2011) to (02/2012) in sql server
本文介绍了如何在SQL Server中将(11/2011)与(02/2012)进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,所有访客,
我有一张桌子.在我的桌子上有很多行,
我想将(11/2011)与(02/2012)进行比较.
注意:11和02是月份,2011和2012是年份.
我如何比较它们?
谢谢
TONY
Hi all visitors,
i have one table.In my table it has many rows,
i want to compare (11/2011) to (02/2012).
note: 11 and 02 are month,2011 and 2012 are year.
How can i compare them?
Thanks
TONY
推荐答案
如果它们是字符串,则必须使用SUBSTRING
函数解析月份和年份.执行此操作时,可以创建一个新的DateTime
变量,然后将该变量与DATEDIFF
函数(以查找两个日期之间的差)或BETWEEN
函数(以查看是否有另一个日期)一起使用两者之间).
使用Google Luke ...
If they''re strings, you have to parse out the month and year using theSUBSTRING
function. When you do that, you can create a newDateTime
variable which can then be used with either theDATEDIFF
function (to find the difference between the two dates), or theBETWEEN
function (to see if another date falls between the two).
Use the Google, Luke...
这篇关于如何在SQL Server中将(11/2011)与(02/2012)进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文