Add Day, Month or Year in date column in sql server
We can add date in sql server with DATEADD function. Example is as below.
Syntax: DATEADD (datepart , number , date )
Complete query will be:
SELECT DATEADD(DAY, 1, '2008-08-30') will result 2008-08-31
SELECT DATEADD(DAY, 2, '2008-08-30') will result 2008-09-01
If want to update any value then we will use it in update statement like below:
Query:
update tbUser set ValidDate=(SELECT DATEADD(month, 6, GETDATE())) where userid=''
http://
http://
Contributed by:
Rohit kakria
I am software developer
Resourse address on xpode.com
http://www.xpode.com/Print.aspx?Articleid=589
Click here to go on website
|