Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

DateAdd

Example

Add two years to a given date.

SELECT DateAdd(“yyyy”2, #22/11/2017#);

Definition and Usage

The DATEADD() function adds a specified time/date interval to a given date and returns the resulting date.

Syntax

DateAdd(intervalnumberdate)

Parameter Values

Parameter

Description

interval

Mandatory. The time/date interval to add, which can be one of the following values:

  • yyyy = Year
  • q = Quarter
  • m = Month
  • y = Day of the year
  • d = Day
  • w = Weekday
  • ww = Week
  • h = Hour
  • n = Minute
  • s = Second

date

Mandatory. The number of intervals to add to the date. This can be positive (for future dates) or negative (for past dates).

time

Mandatory. The date to which the interval will be added.

Technical Details

WORKS IN

From Access 2000

More Examples

Example

Add one year to the current date.

SELECT DateAdd(“yyyy”1, Date());

Example

Add six months to the birth dates of the employees.

SELECT LastName, DateAdd(“m”6, BirthDate) FROM Employees;