콘텐츠로 이동

두 타임스탬프의 차이를 계산하여 INTERVAL로 반환합니다.

func.timestamp_diff(<timestamp1>, <timestamp2>)
func.timestamp_diff(func.to_timestamp('2025-02-01'), func.to_timestamp('2025-01-01'))
┌────────────────────────────────────────────────────────────────────────────────────────┐
│ func.timestamp_diff(func.to_timestamp('2025-02-01'), func.to_timestamp('2025-01-01')) │
├────────────────────────────────────────────────────────────────────────────────────────┤
│ 744:00:00 │
└────────────────────────────────────────────────────────────────────────────────────────┘
TIMESTAMP_DIFF(<timestamp1>, <timestamp2>)

INTERVAL(hours:minutes:seconds 형식)입니다.

이 예시는 2025년 2월 1일과 2025년 1월 1일 사이의 시간 차이가 744시간이며, 이는 31일에 해당함을 보여 줍니다.

SELECT TIMESTAMP_DIFF('2025-02-01'::TIMESTAMP, '2025-01-01'::TIMESTAMP);
┌──────────────────────────────────────────────────────────────────┐
│ timestamp_diff('2025-02-01'::TIMESTAMP, '2025-01-01'::TIMESTAMP) │
├──────────────────────────────────────────────────────────────────┤
│ 744:00:00 │
└──────────────────────────────────────────────────────────────────┘