SQL Server 2005 Using DateAdd to add a day to a date
207,244
Solution 1
Use the following function:
DATEADD(type, value, date)
-
date is the date you want to manipulate
-
value is the integere value you want to add (or subtract if you provide a negative number)
-
type is one of:
-
yy, yyyy: year
-
qq, q: quarter
-
mm, m: month
-
dy, y: day of year
-
dd, d: day
-
wk, ww: week
-
dw, w: weekday
-
hh: hour
-
mi, n: minute
-
ss or s: second
-
ms: millisecond
-
mcs: microsecond
-
ns: nanosecond
SELECT DATEADD(dd, 1, GETDATE()) -- will return a current date + 1 day
http://msdn.microsoft.com/en-us/library/ms186819.aspx
Solution 2
DECLARE @MyDate datetime
-- ... set your datetime's initial value ...'
DATEADD(d, 1, @MyDate)
Solution 3
Try following code will Add one day to current date
select DateAdd(day, 1, GetDate())
And in the same way can use Year, Month, Hour, Second etc. instead of day in the same function
Solution 4
The following query I have used in SQL Server 2008, it may be help you.
For add day
DATEADD(DAY,20,GETDATE())
*20 is the day quantity
Solution 5
DECLARE @date DateTime
SET @date = GetDate()
SET @date = DateAdd(day, 1, @date)
SELECT @date
Author by
test
Updated on January 14, 2020Comments
-
test over 4 years
How do I in SQL Server 2005 use the DateAdd function to add a day to a date
-
GilM over 15 yearsI think you want to use GETDATE() or CURRENT_TIMESTAMP instead of NOW()
-
zisha over 6 yearsThis seems to be an answer to a different question.