我想在两个日期范围之间选择数据,(来自一个日期选择器)。我已经以各种方式构建了我的查询,但仍然没有显示任何记录。我认为它与我的Where声明有关。任何帮助将不胜感激。
Select CampaignName AS 'CAMPAIGN NAME',
campaignDescription AS 'CAMPAIGN DESCRIPTION',
CASE WHEN EndDate >= GETDATE() and StartDate <= GETDATE() THEN 'ACTIVE'
WHEN StartDate >= GETDATE() THEN 'PENDING
'ELSE 'CLOSED' END as 'CURRENT STATUS',
CONVERT(VARCHAR(11), StartDate,106) + ' - ' + CONVERT(VARCHAR(11),EndDate,106)
AS 'CAMPAIGN DATES',
Discount AS 'DISCOUNT',
[Target] AS 'TARGET',
Uptake AS 'UPTAKE',
AddedBy AS 'ADDED BY',
DateAdded AS 'DATE ADDED'
FROM Tbl_Campaign
WHERE EndDate BETWEEN 2015-09-20 AND 2015-10-30
答案 0 :(得分:1)
您必须在以下内容的引号' '
内传递日期:
WHERE EndDate BETWEEN '2015-09-20' AND '2015-10-30'
现在您有INT
2015-09-20
,等于1986