Home

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

day,
hour,
minute,
second,
millisecond;
many
implementations
also
accept
common
abbreviations
such
as
yy
for
year
or
dd
for
day).
number
is
an
integer.
Positive
values
move
forward
in
time;
negative
values
move
backward.
date
is
the
base
date/time
value,
which
can
be
a
date,
datetime,
datetime2,
smalldatetime,
or
similar
types
depending
on
the
database.
a
day
that
does
not
exist
in
the
resulting
month),
behavior
is
defined
by
the
database
system
and
may
adjust
to
the
last
valid
day
or
raise
an
error.
Time
zone
and
offset
considerations
may
apply
if
the
input
includes
such
components.
via
arithmetic
with
intervals
(for
example,
DATE_ADD
in
MySQL,
or
adding
an
INTERVAL
in
PostgreSQL
and
Oracle).
Always
consult
the
respective
documentation
for
precise
syntax
and
behavior.