How to increment date by 1 for number of time in sql statement
18,652
Use the ROW_NUMBER()
as the value to the DATEADD
method.
SELECT
*,
DATEADD(d,ROW_NUMBER() OVER (ORDER BY ID ASC), GETDATE())
FROM
MyTable;
Author by
Sas
I am a new grad software engineering student with big dreams. I enjoy every aspect of programming (coding, bug fix, system designing, etc). Quote: "Typing is no substitute for thinking." — Dartmouth Basic manual, 1964.
Updated on June 05, 2022Comments
-
Sas almost 2 years
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?