달나라 노트

Presto : dow, day_of_week (요일 추출, weekday) 본문

SQL/Presto

Presto : dow, day_of_week (요일 추출, weekday)

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

 

 

 

dow, day_of_week는 주어진 datetime이 무슨 요일인지를 요일 번호로 추출해줍니다.

 

Syntax

dow(datetime)
day_of_week(datetime)

 

주어진 datetime의 요일을 번호로 추출해줍니다.

dow와 day_of_week함수는 동일합니다.

 

아래 표는 각 요일에 해당하는 숫자입니다.

day of week day of week number
Mon 1
Tue 2
Wed 3
Thu 4
Fri 5
Sat 6
Sun 7

 

 

select  current_timestamp as current_dttm  --> 2025-10-18 02:40:06.391
        , dow(current_timestamp) as current_dow  --> 6
        , day_of_week(current_timestamp) as current_day_of_week  --> 6
;

 

current_timestamp는 2025-10-18입니다.

2025년 10월 18일은 토요일이므로 토요일에 해당하는 6이라는 숫자가 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