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.

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=''
Share this article   |    Print    |    Article read by 5003 times
Author:
Rohit kakria
I am software developer
Related Articles:
Related Interview Questions: