SQL > SQL Date Functions > Dateadd Function

The DATEADD function is used to add an interval to a date. This function is available in SQL Server.

DATEADD(datepart, number, expression) adds a specified integer interval to a date or datetime value in SQL Server. Use a negative number to subtract time. The result has the same data type as the input expression.

Syntax

The syntax for the DATEADD function is as follows:

DATEADD (datepart, number, expression)

where the data type of <expression> is some type of date, time, or datetime. <number> is an integer (can be positive or negative). <datepart> can be one of the following:

 datepart  abbreviation 
 year  yy, yyyy 
 quarter  qq, q 
 month  mm, m 
 dayofyear  dy, y 
 day  dd, d 
 week  wk, ww 
 hour  hh 
 minute  mi, n 
 second  ss, s 
 millisecond  ms 
 microsecond  mcs 
 nanosecond  ns 
 TZoffset  tz 
 ISO_WEEK  isowk, isoww 

The result returned has the same data type as <expression>.

Examples

Below we show several examples of the output from applying the DATEADD function.

Example 1

The SQL statement,

SELECT DATEADD (day, 10, '2000-01-05 00:05:00.000');

produces the following result:

'2000-01-15 00:05:00.000'

In this example, we are adding 10 days to the original datetime.

Example 2

The SQL statement,

SELECT DATEADD (hour, -10, '2000-01-05 00:05:00.000');

produces the following result:

'2000-01-04 14:05:00.000'

In this example, we are subtracting 10 hours from the original datetime.

Example 3

The SQL statement,

SELECT DATEADD (mm, 1, '2000-01-05 00:05:00.000');

produces the following result:

'2000-02-15 00:05:00.000'

In this example, we use the abbreviation for "month" to add one month to the original datetime.

List of SQL Date Functions

Function NameDescription
 DATEADD  Adds an interval to a date value in SQL Server. 
 DATEDIFF  Calculates the difference between two dates in MySQL and SQL Server. 
 DATEPART  Extracts a specific part of a date/time value in SQL Server. 
 GETDATE  Retrieves database time in SQL Server. 
 SYSDATE  Retrieves database time in Oracle and MySQL. 
 EXTRACT  Retrieves a certain component of a date or timestamp value. 

Frequently Asked Questions

What does the SQL DATEADD function do?

DATEADD adds (or subtracts when the number is negative) a specified time interval to a date or datetime value. It is available in SQL Server and lets you work with any granularity from nanoseconds to years.

What is the syntax for DATEADD?

DATEADD (datepart, number, expression) — where datepart is the unit to add (year, month, day, hour, etc.), number is the integer amount, and expression is the starting date value.

Can DATEADD subtract dates?

Yes. Pass a negative number to subtract the interval. For example, DATEADD(hour, -10, '2000-01-05 00:05:00.000') subtracts 10 hours, returning '2000-01-04 14:05:00.000'.

What data type does DATEADD return?

DATEADD returns a value with the same data type as the expression argument. If you pass a datetime, you get a datetime back.

Next: SQL DATEDIFF

This page was last updated on March 19, 2026.




Copyright © 2026   1keydata.com   All Rights Reserved     Privacy Policy     About   Contact