반응형
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
- google apps script
- Apache
- Presto
- numpy
- Google Excel
- math
- Redshift
- PANDAS
- PySpark
- django
- c#
- Github
- Tkinter
- Kotlin
- hive
- GIT
- Google Spreadsheet
- Java
- Python
- PostgreSQL
- SQL
- array
- string
- dataframe
- 파이썬
- Excel
- gas
- list
- matplotlib
Archives
- Today
- Total
달나라 노트
Presto : to_char (날짜를 문자로 변환, convert date to text) 본문
728x90
반응형
Presto에서는 Redshift에서와 비슷한 to_char 함수를 제공합니다.
날짜/시간을 텍스트로 바꿔주는 역할을 합니다.
Syntax
to_char(datetime, format)
- datetime
to_char를 적용할 대상 datetime 값입니다.
- format
어떠한 Format으로 바꿀지를 나타냅니다.
특정한 기호를 이용하여 바꿀 수 있습니다.
아래는 날짜 기호를 나타냅니다.
| Keyword | Meaning |
| yyyy | 4자리 년도 |
| yy | 2자리 년도 |
| mm | 2자리 월(01 ~ 12) |
| dd | 2자리 일(01~31) |
| hh24 | 24시 기준 시간(00~23) |
| hh | 12시 기준 시간(1~12) |
| mi | 2자리 분(00~59) |
| ss | 2자리 초(00~59) |
select to_char(current_date, 'yyyymmdd') --> 20251225
, to_char(current_date, 'yyyy-mm-dd') --> 2025-12-25
, to_char(current_date, 'yyyymmdd hh24miss') --> 20251225 000000
, to_char(current_timestamp, 'yyyymmdd') --> 20251225
, to_char(current_timestamp, 'yyyymmdd hh24miss') --> 20251225 135642
;
728x90
반응형
'SQL > Presto' 카테고리의 다른 글
| Presto : year, quarter, month, week, week_of_year, day, day_of_month (날짜 성분 추출하기, 년도, 분기, 월, 주, 일) (0) | 2025.10.18 |
|---|---|
| Presto : date_parse (문자를 날짜/시간으로 변환, convert text to date/time) (0) | 2025.10.03 |
| Presto : substring, substr (문자열 추출하기, 문자열 자르기) (0) | 2025.10.03 |
| Presto : date_add() (시간 더하기, 날짜 더하기, 특정 기간 더하기) (0) | 2023.10.11 |
| Presto : date_diff() (두 시점 간의 차이 구하기, 시간 차이) (2) | 2023.10.10 |
Comments
