SQL在两个日期之间选择

时间:2016-02-18 21:54:48

标签: sql sql-server sql-server-2008

您好我正在寻找能够获得两个日期之间记录的查询

开始日期应为OrderDate + 28天

结束日期应为开始日期+ 4天的结果

选择查询

SELECT dbo.Orders.*, dbo.Customer.* FROM dbo.Orders INNER JOIN dbo.Customer ON dbo.Orders.Cust_ID = dbo.Customer.Cust_ID 

1 个答案:

答案 0 :(得分:2)

使用DATEADD()资金

SELECT dbo.Orders.*, dbo.Customer.* 
FROM dbo.Orders INNER JOIN dbo.Customer ON dbo.Orders.Cust_ID = dbo.Customer.Cust_ID 
WHERE [Start-date] DATEADD(day,28,OrderDate) AND [End-date] = DATEADD(day,4,[Start-date])