如何在SQL Server中将(11/2011)与(02/2012)进行比较 [英] how to compare (11/2011) to (02/2012) in sql server

查看:64
本文介绍了如何在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 the SUBSTRING function. When you do that, you can create a new DateTime variable which can then be used with either the DATEDIFF function (to find the difference between the two dates), or the BETWEEN function (to see if another date falls between the two).

Use the Google, Luke...


这篇关于如何在SQL Server中将(11/2011)与(02/2012)进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆