2013-03-06 135 views
-1
SELECT '(Current Week)' 
UNION SELECT Convert(varchar, dbo.firstOfWeek(DateAdd(dd, -7, GetDate()), default), 101) 
UNION SELECT Convert(varchar, dbo.firstOfWeek(DateAdd(dd, -14, GetDate()), default), 101) 
UNION SELECT Convert(varchar, dbo.firstOfWeek(DateAdd(dd, -21, GetDate()), default), 101) 
UNION SELECT Convert(varchar, dbo.firstOfWeek(DateAdd(dd, -28, GetDate()), default), 101) 
UNION SELECT Convert(varchar, dbo.firstOfWeek(DateAdd(dd, -35, GetDate()), default), 101) 
UNION SELECT Convert(varchar, dbo.firstOfWeek(DateAdd(dd, -42, GetDate()), default), 101) 
order by 1 
+0

http://www.sqlfiddle.com – BLSully 2013-03-06 20:03:57

+1

沒有任何的背景下,[它給了一些錯誤(http://www.sqlfiddle.com/# !3/d41d8/10460),這是可以預料的。 – Dukeling 2013-03-06 20:06:04

+1

你們很快就會發現問題並關閉它。至少讓OP有機會澄清他在關閉之前試圖達成的目標。也許在弓上發出警告聲吧? – Tim 2013-03-06 20:16:04

回答

0

我想你的意思是這樣的:

SELECT '(Current Week)' 
UNION SELECT Convert(varchar, DateAdd(dd, -7, GetDate()), 101) 
UNION SELECT Convert(varchar, DateAdd(dd, -14, GetDate()), 101) 
UNION SELECT Convert(varchar, DateAdd(dd, -21, GetDate()), 101) 
UNION SELECT Convert(varchar, DateAdd(dd, -28, GetDate()), 101) 
UNION SELECT Convert(varchar, DateAdd(dd, -35, GetDate()), 101) 
UNION SELECT Convert(varchar, DateAdd(dd, -42, GetDate()), 101) 
order by 1 

(Current Week) 
01/23/2013 
01/30/2013 
02/06/2013 
02/13/2013 
02/20/2013 
02/27/2013