generate date list in sql between two given dates
  • we can create list of dates from given date range in sql server by below query .

    Declare @DateFrom datetime
    Declare @DateTo datetime

    Set @DateFrom='2015-07-01'
    Set @DateTo='2015-07-31'

    Declare @Days int
    Declare @Index int

    SET @Index=1
    SET @Days=(SELECT DATEDIFF(dd, @DateFrom, @DateTo)+1)

    declare @TDate table(SNo int, Date Datetime)


    Insert Into @TDate(SNo, Date) Values (@Index, DATEADD(dd, @Index-1, @DateFrom))

    SET @Days=@Days-1
    SET @Index=@Index+1

    SELECT * FROM @TDate

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook


Popular Posts of the Week

    Optimum Creative