반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- PySpark
- matplotlib
- PANDAS
- Kotlin
- Github
- gas
- Google Excel
- Python
- Tkinter
- Excel
- SQL
- string
- numpy
- PostgreSQL
- dataframe
- google apps script
- Java
- 파이썬
- django
- c#
- array
- Google Spreadsheet
- list
- math
- hive
- Apache
- GIT
- Mac
- Redshift
Archives
- Today
- Total
달나라 노트
Redshift : last_day() (특정 날짜가 속한 월의 가장 마지막 날짜 return) 본문
728x90
반응형
Redshift의 last_day 함수는 특정 날짜가 속한 달의 마지막 날짜를 return해줍니다.
Syntax
last_day(date or timestamp)
사용법은 간단합니다.
parameter로써 날짜 type의 데이터나 timestamp type의 데이터를 받습니다.
select last_day(to_date('20230216', 'yyyymmdd'))
;
-- Result
2023-02-28
위 예시는 last_day 함수에 20230216이라는 날짜를 전달한 것입니다.
(날짜를 전달할 땐 to_date 함수를이용해서 날짜 형식으로 바꿔줍니다.)
결과를 보면 2023년 2월의 마지막 날짜인 2023-02-28이 return됩니다.
select last_day(to_date('20230908', 'yyyymmdd'))
;
-- Result
2023-09-30
위 예시는 last_day 함수에 20230908이라는 날짜를 전달한 것입니다.
(날짜를 전달할 땐 to_date 함수를이용해서 날짜 형식으로 바꿔줍니다.)
결과를 보면 2023년 9월의 마지막 날짜인 2023-09-30이 return됩니다.
728x90
반응형
'SQL > Redshift' 카테고리의 다른 글
Redshift : json_extract_array_element_text() (Redshift에서 array indexing하기, array 선택하기, array 값 추출) (0) | 2023.08.04 |
---|---|
Redshift : json_extract_path_text() (Redshift에서 JSON data 참조하기, Redshift dictionary) (0) | 2023.08.04 |
Redshift : table 생성 일시 추출, table 생성 시점 추출 (0) | 2023.01.31 |
Redshift : pg_tables (table 종류, owner 종류 추출) (0) | 2023.01.31 |
Redshift : set timezone (timezone 설정, 시간대 설정) (0) | 2023.01.31 |
Comments