카테고리 없음

[SQL] postgresql의 mmm yyyy 형식의 날짜

행복을전해요 2020. 12. 13. 08:37

SELECT TO_CHAR(NOW(), 'Mon YYYY');

-------------------

DateAndTime 형식 변경 :

SELECT *, to_char( last_update, 'DD-MON-YYYY') as re_format from actor;

데모:

여기에 이미지 설명 입력

-------------------

날짜 형식 지정 함수 (예 : to_char http://www.postgresql.org/docs/current/static/functions-formatting.html) 를 사용해야합니다 .

-------------------

선택 쿼리를 다음과 같이 작성할 수 있습니다.

select * from table_name where to_char(date_time_column, 'YYYY-MM')  = '2011-03';
-------------------

Postgres에서는 예를 들어 원하는 경우 형식으로 재생할 수 있다고 생각합니다. dd/mm/yyyy

TO_CHAR(submit_time, 'DD/MM/YYYY') as submit_date


출처
https://stackoverflow.com/questions/7415077