달나라 노트

Presto : last_day_of_month (특정 월의 마지막 날짜 구하기) 본문

SQL/Presto

Presto : last_day_of_month (특정 월의 마지막 날짜 구하기)

CosmosProject 2025. 10. 18. 11:50
728x90
반응형

 

 

 

Presto의 last_day_of_month는 특정 시점에 해당하는 월의 마지막 날짜를 return합니다.

 

Syntax

last_day_of_month(datetime)

 

주어진 datetime에 해당하는 월(month)의 마지막 날짜를 return합니다.

 

 

 

 

select  current_timestamp as current_dttm  --> 2025-10-18 02:40:06.3691
        , last_day_of_month(current_timestamp)  --> 2025-10-31
;

 

위 예시를 보면 현재 시점은 2025-10-18입니다.

last_day_of_month함수는 2025년 10월의 마지막 날인 2025-10-31을 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