나는야 데이터사이언티스트/SQL Trouble Shooting

unix epoch time SQL로 바꾸는 방법

우주먼지의하루 2021. 5. 25. 00:02
728x90

aws athena 하는 중에 timestamp가 unix epoch time으로 나오는 문제때문에 찾은 방법입니다.

 

 

기본적으로 unix epoch time을 SQL로 바꾸는 방법은 다음과 같습니다.

FROM_UNIXTIME(time)

 

 

하지만 제가 찾은 방법은 다음과 같습니다(이것 사용 !!!)

from_unixtime(timerecv / 1000e0)

 

 

혹시 안되면 date_format도 한번 넣어보세요

date_format(from_unixtime(timerecv),'%Y-%m')

 

 

▼잘 바뀌었는지 확인 !

 

www.epochconverter.com/

 

Epoch Converter

Convert Unix Timestamps (and many other date formats) to regular dates.

www.epochconverter.com

 

반응형