달나라 노트

Presto : hour, minute, second, millisecond (시간 성분 추출하기, 시간, 분, 초, 밀리초) 본문

SQL/Presto

Presto : hour, minute, second, millisecond (시간 성분 추출하기, 시간, 분, 초, 밀리초)

CosmosProject 2025. 10. 18. 12:12
728x90
반응형

 

 

 

Presto에서 사용할 수 있는 시간 성분을 추출하는 함수를 알아봅시다.

 

Function name Description
hour(datetime) 주어진 datetime의 시간(hour)성분을 추출합니다.
minute(datetime) 주어진 datetime의 분(minute)성분을 추출합니다.
second(datetime) 주어진 datetime의 초(second)성분을 추출합니다.
millisecond(datetime) 주어진 datetime의 밀리초(millisecond)성분을 추출합니다.

 

 

 

 

select  current_timestamp as current_dttm  --> 2025-10-18 03:13:54.561
        , hour(current_timestamp) as current_hour  --> 3
        , minute(current_timestamp) as current_minute  --> 13
        , second(current_timestamp) as current_second  --> 54
        , millisecond(current_timestamp) as current_millisecond  --> 561
;

 

 

현재 시점은 2025-10-18 03:13:54.561 입니다.

여기서 각각의 함수의 결과를 보면 시/분/초/밀리초를 제대로 return한 것을 볼 수 있습니다.

 

 

 

FYI

https://prestodb.io/docs/current/functions/datetime.html#dow-x-bigint

 

Date and Time Functions and Operators - Presto 0.295 Documentation

Date and Time Functions and Operators Date and Time Operators Operator Example Result + date '2012-08-08' + interval '2' day 2012-08-10 + time '01:00' + interval '3' hour 04:00:00.000 + timestamp '2012-08-08 01:00' + interval '29' hour 2012-08-09 06:00:00.

prestodb.io

 

 

 

 

 

 

728x90
반응형
Comments