在T SQL中的两个日期之间找到日期 [英] find a date between two dates in T SQL

查看:213
本文介绍了在T SQL中的两个日期之间找到日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表中有两个DateTime列,ArrivalDateTime,DepartureDateTime等值为'26/11/2012 00:00:00''28 / 11/2012 00:00:00'现在我想查找所有的记录使用T Sql

I have two DateTime columns in my table, ArrivalDateTime,DepartureDateTime with values like '26/11/2012 00:00:00' '28/11/2012 00:00:00' Now I want to find all the records from this table where a given date say 27/11/2012 exist between those dates using T Sql

推荐答案

可以使用 href =http://msdn.microsoft.com/en-us/library/ms187922.aspx =noreferrer> BETWEEN

SELECT * FROM table 
WHERE '2012-11-27' BETWEEN ArrivalDateTime AND DepartureDateTime

这篇关于在T SQL中的两个日期之间找到日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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