SELECT DATE_PART('DAYS', CURRENT_TIMESTAMP AT TIME ZONE
'Asia/Seoul' - '2024-01-01 00:00:00'::TIMESTAMP) AS DIFF,
CURRENT_TIMESTAMP AT TIME ZONE 'Asia/Seoul' - '2023-01-01 00:00:00'::TIMESTAMP AS DIFF2;
*DATE_PART ์ field ์์ ์ง์ํ๋ ํ์ ๋ชฉ๋ก์ ๊ฐ๋ตํ๊ฒ ์๊ฐ
century
decade
year
month
day
hour
minute
second
microseconds
milliseconds
dow
doy
epoch
isodow
isoyear
timezone
timezone_hour
timezone_minute
์์
์ฌ์ฉ ๋ฐฉ๋ฒ์ ์๋์ ๊ฐ๋ค.
์ฟผ๋ฆฌ
SELECT CURRENT_TIMESTAMP AT TIME ZONE
'Asia/Seoul' AS TODAY,
'2024-01-01 00:00:00'::TIMESTAMP AS DIFFDATE,
DATE_PART('DAY', CURRENT_TIMESTAMP AT TIME ZONE
'Asia/Seoul' - '2024-01-01 00:00:00'::TIMESTAMP) AS DIFF_V1,
CURRENT_TIMESTAMP AT TIME ZONE 'Asia/Seoul' - '2024-01-01 00:00:00'::TIMESTAMP AS DIFF_V2