查询日期之间 [英] Querying in between to dates
本文介绍了查询日期之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友们,
对于查询此表,我在SQL中有疑问
Hi friends,
I have a doubt in SQL regarding querying this table
CREATE TABLE [dbo].[tbl_Trans_LeaveRequestApproval]
(
[FromDate] [datetime] NOT NULL,
[ToDate] [datetime] NOT NULL,
-- other columns to follow here
-- ...
)
假设我插入了一条记录,FromDate为"21-05-2012",ToDate为"28-05-2012",现在我想要两个日期之间的日期.
我该如何查询?
在此先感谢!
Suppose I have inserted a record with FromDate as ''21-05-2012'' and ToDate as ''28-05-2012'' and now I want the dates inbetween the two dates.
How do i make a query for this?
Thanks in advance!
推荐答案
尝试
SELECT * FROM myTable WHERE myDateField BETWEEN ''21-05-2012'' AND ''28-05-2012''
请参考 ^ ]
您必须使用 BETWEEN operator ..
refer http://database.ittoolbox.com/groups/technical-functional/sql-l/selecting-between-two-dates-within-a-datetime-field-sql-server-610522[^]
you have to use BETWEEN operator ..
查看此链接,您可能会有所了解
http://msdn.microsoft.com/en-us/library/ms189794.aspx [ ^ ]
See this link you may get some idea
http://msdn.microsoft.com/en-us/library/ms189794.aspx[^]
这篇关于查询日期之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文