My Blog List

hotinit.com. Powered by Blogger.

Search This Blog

Showing posts with label funtion to display dates between two dates. Show all posts
Showing posts with label funtion to display dates between two dates. Show all posts

Display Dates Between Two Dates in Sql Server

Thursday, 15 September 2011



DECLARE @StartDate DATETIME
SET @StartDate = '02/26/1988'

DECLARE @EndDate DATETIME
SET @EndDate = '03/01/1988'

DECLARE @TableOfDates TABLE(DateValue DATETIME)

DECLARE @CurrentDate DATETIME

SET @CurrentDate = @startDate

WHILE @CurrentDate <= @endDate
BEGIN
    INSERT INTO @TableOfDates(DateValue) VALUES (@CurrentDate)

    SET @CurrentDate = DATEADD(DAY, 1, @CurrentDate)
END

SELECT * FROM @TableOfDates

 

Blogger news

Blogroll

Most Reading

8.6/10