2017-09-06 5 views
0

하이브 쿼리가 있는데 next_datetimecurr_datetime의 차이가 1 시간을 넘지 않았는지 확인하고 싶습니다.두 datetime 필드 사이의 시간 차이를 확인하는 방법은 무엇입니까?

이 AND 절을 추가하면 두 datetime이 같은 시간인지 확인합니다.

<...> and hour(next_datetime) = hour(curr_datetime) 

몇 분 안에 시간 차이가 있습니까? next_datetimecurr_datetime은 다른 날짜에 속할 수도 있습니다.

+0

저는 컴퓨터 근처에 없습니다. '... and next_datetime - curr_datetime <= interval '1'hour'을 시도해 볼 수 있습니다. –

답변

2

unix_timestamp을 사용해보고 시간 차이가 3600 초 미만인지 확인하십시오.

<...> and (unix_timestamp(next_datetime) - unix_timestamp(curr_datetime) <= 3600)