Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     

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.

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:

update tbUser set ValidDate=(SELECT DATEADD(month, 6, GETDATE())) 
where userid=''
Share this article   |    Print    |    Article read by 4124 times
Rohit kakria
I am software developer
Related Articles:
Related Interview Questions: