일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 파이썬
- Kotlin
- Apache
- Java
- Redshift
- matplotlib
- dataframe
- Google Spreadsheet
- Python
- django
- numpy
- PANDAS
- PostgreSQL
- SQL
- google apps script
- Tkinter
- Google Excel
- PySpark
- Github
- Excel
- string
- gas
- GIT
- Mac
- hive
- list
- array
- math
- c#
- Today
- Total
목록Day (4)
달나라 노트
Syntax dayofmonth(date_string/timestamp_string) -> 주어진 일자에 대해 일을 return합니다. dayofweek(date_string/timestamp_string) -> 주어진 일자에 대해 요일 번호를 return합니다. weekofyear(date_string/timestamp_string) -> 주어진 일자에 대해 weeknumber를 return합니다. select dayofmonth('2020-11-10') --> 10 , dayofmonth('2020-11-10 12:34:56') --> 10 ; - dayofmonth('2020-11-10') 2020-11-10에서 일(day)을 추출합니다. 따라서 10이 return됩니다. - dayofmonth('..
Presto에서 날짜나 시간을 더하고 빼기 위해선 interval 함수를 사용하면 됩니다. select current_date, --> 2022-01-14 timestamp '2022-01-14 15:23:43' + interval '1' second, --> 2022-01-14 15:23:44 timestamp '2022-01-14 15:23:43' - interval '1' second, --> 2022-01-14 15:23:42 timestamp '2022-01-14 15:23:43' + interval '1' minute, --> 2022-01-14 15:24:43 timestamp '2022-01-14 15:23:43' - interval '1' minute, --> 2022-01-14 15:2..
import datetime today = datetime.date.today() y = today.year m = today.month d = today.day w = today.weekday() print(y) print(m) print(d) print(w) - Result 2020 3 8 6 datetime 모듈의 date class에 today method를 사용하거나 직접 년, 월, 일을 입력해주어 date 객체를 생성합니다. 이 생성한 date class의 year, month, day attribute를 이용하여 년, 월, 일을 추출할 수 있으며 weekday method를 이용하여 요일별 숫자(월 = 0, 화 = 1, ... 일 = 6)를 얻어낼 수 있습니다.
year(date_string) month(date_string) day(date_string) quarter(date_string) hour(date_string) minute(date_string) second(date_string) 각 함수는 위처럼 date string을 받아 date string에 있는 년, 월, 일, 분기, 시, 분, 초를 integer의 형태로 반환합니다. select year('2020-11-10'); -> 결과 : 2020 select year('2020-11-10 12:34:56'); -> 결과 : 2020 select month('2020-11-10'); -> 결과 : 11 select month('2020-11-10 12:34:56'); -> 결과 : 11 selec..