SQL Server DATEADD() 함수
예시
날짜에 1년을 더한 다음 날짜를 반환합니다.
SELECT DATEADD(year, 1, '2017/08/25') AS DateAdd;
정의 및 사용
DATEADD() 함수는 날짜에 시간/날짜 간격을 추가한 다음 날짜를 반환합니다.
통사론
DATEADD(interval, number, date)
매개변수 값
Parameter | Description |
---|---|
interval | Required. The time/date interval to add. Can be one of the following values:
|
number | Required. The number of interval to add to date. Can be positive (to get dates in the future) or negative (to get dates in the past) |
date | Required. The date that will be modified |
기술적 세부 사항
작동: | SQL Server(2008부터), Azure SQL Database, Azure SQL Data Warehouse, 병렬 데이터 웨어하우스 |
---|
더 많은 예
예시
날짜에 2개월을 더한 다음 날짜를 반환합니다.
SELECT DATEADD(month, 2, '2017/08/25') AS DateAdd;
예시
날짜에서 두 달을 뺀 다음 날짜를 반환합니다.
SELECT DATEADD(month, -2, '2017/08/25') AS DateAdd;
예시
BirthDate 열의 날짜에 18년을 더한 다음 날짜를 반환합니다.
SELECT LastName,
BirthDate, DATEADD(year, 18, BirthDate) AS DateAdd FROM Employees;