반응형
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 | 31 |
Tags
- GIT
- matplotlib
- numpy
- Python
- Github
- string
- Kotlin
- Google Spreadsheet
- PANDAS
- Excel
- hive
- math
- Google Excel
- list
- 파이썬
- django
- Java
- gas
- Tkinter
- array
- Redshift
- Apache
- google apps script
- SQL
- PySpark
- PostgreSQL
- Mac
- dataframe
- c#
Archives
- Today
- Total
달나라 노트
Hive : date_add(), date_sub() (특정 일 수 더하고 빼기) 본문
728x90
반응형
date_add(날짜data/날짜 string, days number)
date_sub(날짜data/날짜 string, days number)
date_add는 주어진 날짜data/날짜 string에서 days number만큼 더한 날짜를 반환합니다.
date_sub은 주어진 날짜data/날짜 string에서 days number만큼 뺀 날짜를 반환합니다.
select current_date;
결과 : 2021-08-25
select date_add(current_date, 2);
결과 : 2021-08-27
select date_add(current_date, 30);
결과 : 2021-09-24
select date_sub(current_date, 2);
결과 : 2021-08-23
select date_sub(current_date, 30);
결과 : 2021-07-26
select date_add('2020-11-12', 2);
결과 : 2020-11-14
select date_add('2020-11-12', 30);
결과 : 2020-12-12
select date_sub('2020-11-12', 2);
결과 : 2020-11-10
select date_sub('2020-11-12', 30);
결과 : 2020-10-13
select date_add('2020-11-10 12:34:56', 2);
결과 : 2020-11-12
select date_add('2020-11-10 12:34:56', 30);
결과 : 2020-12-10
select date_sub('2020-11-10 12:34:56', 2);
결과 : 2020-11-08
select date_sub('2020-11-10 12:34:56', 30);
결과 : 2020-10-11
timestamp를 전달할 수도 있습니다.
728x90
반응형
'SQL > Apache Hive' 카테고리의 다른 글
Hive : date_format() (날짜 format 변경) (0) | 2020.12.17 |
---|---|
Hive : cast() (데이터 형식 변환) (0) | 2020.12.17 |
Hive : year(), month(), day(), quarter(), hour(), minute(), second() (날짜, 시간 요소 추출) (0) | 2020.12.17 |
Hive : to_date() (timestap를 date로 변환) (0) | 2020.12.17 |
Hive : unix_timestamp & from_unixtime (yyyymmdd 형태의 텍스트를 date type으로 바꾸기. 날짜와 unix_timestamp간의 변환) (0) | 2020.12.17 |
Comments