Excel (VBA):
Sub EnumDates()
Dim curDate As Date, fromDate As Date, toDate As Date
Dim i As Integer
i = 1
fromDate = DateSerial(2013, 1, 1)
toDate = DateSerial(2013, 3, 31)
curDate = fromDate - 1
Do While curDate < toDate
curDate = curDate + 1
With ThisWorkbook.Worksheets(1).Range("A" & i)
.NumberFormat = "yyyy-MM-dd"
.Value = curDate
End With
With ThisWorkbook.Worksheets(1).Range("B" & i)
.NumberFormat = "dddd"
.Value = curDate
End With
i = i + 1
Loop
End Sub
SQL:
DECLARE @curDate DATETIME
DECLARE @fromDate DATETIME
DECLARE @toDate DATETIME
SET @fromDate = '2013-01-01'
SET @toDate = '2013-03-31'
SET @curDate = @fromDate -1
;WITH dates AS
(
SELECT @curDate +1 As MyDate, DATENAME(dw, @curDate +1) AS MyDayName
UNION ALL
SELECT MyDate +1, DATENAME(dw, MyDate +1) AS MyDayName
FROM dates
WHERE MyDate<@toDate
)
SELECT *
FROM dates