PostgreSQL 시간 조회

 

현재 시간 조회

 postgres=# select now();

현재 타임존 조회

postgres=# show timezone;

타임존 변경 방법

 postgres=# SET TIME ZONE 'Asia/Seoul';

시스템 일자

postgres=# select current_date, current_time, timeofday(); 
postgres=# select now(), current_timestamp, timestamp 'now';

년도 추출

postgres=# select date_part('year', current_timestamp);

월 추출

postgres=# select date_part('month', current_timestamp);

일 추출

postgres=# select date_part('day', current_timestamp);

분 추출

postgres=# select date_part('minute', current_timestamp);

초 추출

postgres=# select date_part('second', current_timestamp);

요일/일차 추출

postgres=# select extract('dow' from timestamp '2013-07-30 20:38:40');    -- 일요일(0), 토요일(6)
result: 5

postgres=# select extract('isodow' from timestamp '2013-07-30 20:38:40'); -- 월요일(1), 일요일(7)
result: 5
postgres=# select extract('doy' from timestamp '2013-07-30 20:38:40');
소셜 미디어로 공유하기

You may also like...

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.

 

새 블로그로 이사갑니다.

 

rastalion.dev

 

도메인 변경했어요. 현재 지속적으로 개선 중입니다.

 

This will close in 10 seconds