declare @startdate datetime='11/30/2012',@enddate datetime='12/6/2012'
Select
Convert(varchar, DateAdd(dd, -(DatePart(dw, @startdate) - 1), @startdate), 101) As WeekStart,
Convert(varchar, DateAdd(dd, (7 - DatePart(dw, @enddate)), @enddate), 101) As WeekEnd
上面是代码,代码的输出是:
11/25 2012 12/08/2012
但我想在 2 周内分别显示结果。请问如何以这种格式显示数据?
11/25/2012 12/01/2012 ( 1 week)
12/02/2012 12/08/2012 ( 2 week)