sql add date – DATEADD(): Functions is used when we want to get date by adding days or month or year in given date. The ADDDATE() function adds a time/date interval to a date and then returns the date.
sql add date – DATEADD SQL function introduction and overview
sql add date – DATEADD(), How to get new date by adding Days, month or years in MS SQL database? . We can use the SQL SERVER DATEADD function to get a new column after adding the required date value.
Syntax : DATEADD Function
DATEADD( interval, number, date )
Syntax – DATEADD(DATEPART, number, datecolumn)
GETDATE AND ADD DAYS SQL
sql server current date minus 5 years
SELECT GETDATE() 'Today', DATEADD(day,-2,GETDATE()) 'Today - 2 Days' SELECT GETDATE() 'Today', DATEADD(dd,-2,GETDATE()) 'Today - 2 Days' SELECT GETDATE() 'Today', DATEADD(d,-2,GETDATE()) 'Today - 2 Days'
datetime add 2 hours sql
DATEADD(HOUR, 2, GETUTCDATE())
The following table lists the valid values of date_part:
How to add days to the current date?
Select (Getdate()+360) As MyDate
How to add time to DateTime in SQL
SELECT DATEADD(day, DATEDIFF(day, 0, GETDATE()), '03:30:00')
Query to get Date & time after 6 days from current datetime in MS SQL:
Select DATEADD(DAY, 6, GETDATE()) as NewDatetime
Query to get Date & time 6 days ago from current datetime in MS SQL:
Select DATEADD(DAY, -6, GETDATE()) as NewDatetime
Add 6 Months to Current Date:
Select DATEADD(MONTH, 6, GETDATE()) as NewDatetime
Add 6 years to Current Date:
Select DATEADD(YEAR, 6, GETDATE()) as NewDatetime
Don’t Miss : How To Insert Date In Mysql Using Php?
I hope you get an idea about sql add date.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.