使用选定日期将选定日期列表绑定到网格视图

时间:2014-06-02 11:06:55

标签: c# sql gridview

我想通过bind

绑定网格看起来像这样或sql查询

看起来像

enter image description here

1 个答案:

答案 0 :(得分:2)

DECLARE @startDate DATETIME
DECLARE @endDate DATETIME
SET @startDate = '2014-06-02'
SET @endDate = '2014-06-26'
;WITH dates AS 
(
    SELECT @startdate as Date,DATENAME(Dw,@startdate) As DayName
    UNION ALL
    SELECT DATEADD(d,1,[Date]),DATENAME(Dw,DATEADD(d,1,[Date])) as DayName
    FROM dates 
    WHERE DATE < @enddate
)

SELECT Date,DayName frOM dates where DAYNAME in('Monday','Tuesday','Wednesday')