How to add or subtract days or time in SQL Server using the DATEADD Function

preview_player
Показать описание
In this video, we will be add a time period to a date in SQL Server using the DATEADD function.
My SQL Server Udemy courses are:
----
My Excel for PC courses are:
----
The DATEADD function does allow you to add durations to dates. However, despite its name, it also allows you to add to time, and to subtract from dates and time. For example, you might want the day after, the day before, the next year, or the previous hour.
DATEADD can add multiple or a single year, quarter, month, week, day, hour, minute, second, millisecond, microsecond or nanosecond.
It can be used for fields of the data types date, datetime, datetimeoffset, datetime2, smalldatetime or time.
Рекомендации по теме
Комментарии
Автор

Thank you very much for your valuable information.
I've tried Date_ADD(Date1, Interval 1 Day) As Nxt_Day but it didn't work on my current version of SQL Server and I've spent couple of hours to identify for alternate to Date_ADD function. Finally your video helped me a lot with DateADD function, Thank again ---- Chiroo

ChirooP
Автор

Las Vegas, Nevada, USA: Thanks! I see how to add to a single, specific, hard-coded datetime but what if I want to add a year to every datetime value in a column with multiple rows? I tried your syntax putting the datetime column name after the = but it doesn't work. Thanks!

lisaamante
Автор

Can you make a video on how to add only workdays(Excluding Holidays) to a dynamic date.
For example. ApplicationDate + 3 workdays = ?
*The application date can be any day of the week or holiday.

trevorseth