DATEADD
DATEADD is a date and time arithmetic function primarily associated with SQL Server's Transact-SQL. It returns a new date/time value obtained by adding a specified interval to a given date/time input. The function is widely used in queries, stored procedures, and ETL processes to shift dates forward or backward by a given amount.
Syntax: DATEADD(datepart, number, date). datepart is the component to be added (for example year, quarter, month,
Return type: The function returns a value of the same data type as the input date.
Examples: DATEADD(day, 7, '2023-01-01') yields 2023-01-08. DATEADD(month, -1, '2023-05-15') yields 2023-04-15.
Notes: When the resulting date is invalid for the target date part (for example, adding months to
Portability: DATEADD is specific to SQL Server; other databases provide similar functionality under different names or