How to increment date by 1 for number of time in sql statement

database, sql, sql-server, t-sql

Solution

Use the `ROW_NUMBER()` as the value to the `DATEADD` method.

SELECT
    *, 
    DATEADD(d,ROW_NUMBER() OVER (ORDER BY ID ASC), GETDATE())
FROM 
    MyTable;

Problem

I am trying to increment date by one for some limited number of time. I was able to increment the current date by 1: ``` Select *, DATEADD(d,1, GETDATE()) From MyTable; ``` But I want to increment the date for number of time in each row Like: ``` ID Date 1 2012-05-14 2 2012-05-15 3 2012-05-16 ``` How can do this?

Original source