TIMECONVERT

TIMECONVERT

TIMECONVERT 함수는 에포크 타임스탬프를 포함한 컬럼의 값을 다른 시간 단위로 변환하는 함수예요. 변환된 값은 내림 처리돼요.

출처: 문서

본문

에포크 타임스탬프를 포함한 컬럼의 값을 다른 시간 단위로 변환해요. 변환된 값은 내림 처리돼요.

시그니처 (Signature)

TIMECONVERT(col, fromUnit, toUnit)

지원되는 단위는 다음과 같아요:

  • DAYS
  • HOURS
  • MINUTES
  • SECONDS
  • MILLISECONDS
  • MICROSECONDS
  • NANOSECONDS

사용 예시 (Usage Examples)

다음 예시는 Batch JSON Quick Start를 기반으로 해요.

select id, 
       created_at_timestamp, 
       cast(created_at_timestamp AS long) AS timeInMs,
       TIMECONVERT(created_at_timestamp, 'MILLISECONDS', 'DAYS') AS convertedTime
from githubEvents
LIMIT 1
id created_at_timestamp timeInMs convertedTime
7044874109 2018-01-01 11:00:00.0 1514804400000 17532
select id, 
       created_at_timestamp, 
       cast(created_at_timestamp AS long) AS timeInMs,
       TIMECONVERT(created_at_timestamp, 'MILLISECONDS', 'HOURS') AS convertedTime
from githubEvents
LIMIT 1
id created_at_timestamp timeInMs convertedTime
7044874109 2018-01-01 11:00:00.0 1514804400000 420779
select id, 
       created_at_timestamp, 
       cast(created_at_timestamp AS long) AS timeInMs,
       TIMECONVERT(created_at_timestamp, 'MILLISECONDS', 'SECONDS') AS convertedTime
from githubEvents
LIMIT 1
id created_at_timestamp timeInMs convertedTime
7044874109 2018-01-01 11:00:00.0 1514804400000 1514804400
select id, 
       created_at_timestamp, 
       cast(created_at_timestamp AS long) AS timeInMs,
       TIMECONVERT(created_at_timestamp, 'MILLISECONDS', 'MILLISECONDS') AS convertedTime
from githubEvents
LIMIT 1
id created_at_timestamp timeInMs convertedTime
7044874109 2018-01-01 11:00:00.0 1514804400000 1514804400000
select id, 
       created_at_timestamp, 
       cast(created_at_timestamp AS long) AS timeInMs,
       TIMECONVERT(created_at_timestamp, 'MILLISECONDS', 'MICROSECONDS') AS convertedTime
from githubEvents
LIMIT 1
id created_at_timestamp timeInMs convertedTime
7044874109 2018-01-01 11:00:00.0 1514804400000 1514804400000000
select id, 
       created_at_timestamp, 
       cast(created_at_timestamp AS long) AS timeInMs,
       TIMECONVERT(created_at_timestamp, 'MILLISECONDS', 'NANOSECONDS') AS convertedTime
from githubEvents
LIMIT 1
id created_at_timestamp timeInMs convertedTime
7044874109 2018-01-01 11:00:00.0 1514804400000 1514804400000000000

더 알아보기 (Learn more)