

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# Amazon QLDB의 DATE\$1DIFF 함수
<a name="ql-functions.date_diff"></a>

**중요**  
지원 종료 공지: 기존 고객은 07/31/2025에 지원이 종료될 때까지 Amazon QLDB를 사용할 수 있습니다. 자세한 내용은 [Amazon QLDB 원장을 Amazon Aurora PostgreSQL로 마이그레이션](https://aws.amazon.com/blogs/database/migrate-an-amazon-qldb-ledger-to-amazon-aurora-postgresql/)을 참조하세요.

Amazon QLDB에서 `DATE_DIFF` 함수를 사용하여 주어진 두 타임스탬프의 지정된 날짜 부분 간의 차이를 반환합니다.

## 구문
<a name="ql-functions.date_diff.syntax"></a>

```
DATE_DIFF( datetimepart, timestamp1, timestamp2 )
```

## 인수
<a name="ql-functions.date_diff.arguments"></a>

*datetimepart*  
함수가 실행되는 날짜 또는 시간 부분입니다. 이 파라미터는 다음 중 하나일 수 있습니다:  
+ `year`
+ `month`
+ `day`
+ `hour`
+ `minute`
+ `second`

*timestamp1*, *timestamp2*  
함수가 비교하는 데이터 타입 `timestamp`의 두 개의 필드 명칭 또는 표현식입니다. *timestamp2*가 *timestamp1*보다 이후인 경우 결과는 양수입니다. *timestamp2*가 *timestamp1*보다 이전인 경우 결과는 음수입니다.  
Ion 타임스탬프 리터럴 값은 백틱(``...``)으로 표시할 수 있습니다. 형식 지정 세부 정보 및 타임스탬프 값의 예는 Amazon Ion 사양 문서의 [타임스탬프](https://amzn.github.io/ion-docs/docs/spec.html#timestamp)를 참조하세요.

## 반환 타입
<a name="ql-functions.date_diff.return-type"></a>

`int`

## 예
<a name="ql-functions.date_diff.examples"></a>

```
DATE_DIFF(year, `2010-01-01T`, `2011-01-01T`)            -- 1
DATE_DIFF(year, `2010-12T`, `2011-01T`)                  -- 0 (must be at least 12 months apart to evaluate as a 1 year difference)
DATE_DIFF(month, `2010T`, `2010-05T`)                    -- 4 (2010T is equivalent to 2010-01-01T00:00:00.000Z)
DATE_DIFF(month, `2010T`, `2011T`)                       -- 12
DATE_DIFF(month, `2011T`, `2010T`)                       -- -12
DATE_DIFF(month, `2010-12-31T`, `2011-01-01T`)           -- 0 (must be at least a full month apart to evaluate as a 1 month difference)
DATE_DIFF(day, `2010-01-01T23:00Z`, `2010-01-02T01:00Z`) -- 0 (must be at least 24 hours apart to evaluate as a 1 day difference)

-- Runnable statements
SELECT DATE_DIFF(year, `2010-01-01T`, `2011-01-01T`) FROM << 0 >> -- 1
SELECT DATE_DIFF(month, `2010T`, `2010-05T`) FROM << 0 >>         -- 4
```

## 관련 함수
<a name="ql-functions.date_diff.related"></a>
+ [DATE\$1ADD](ql-functions.date_add.md)
+ [EXTRACT](ql-functions.extract.md)
+ [TO\$1STRING](ql-functions.to_string.md)
+ [TO\$1TIMESTAMP](ql-functions.to_timestamp.md)
+ [UTCNOW](ql-functions.utcnow.md)