문자열을 DATE / TIMESTAMP
SELECT '1733122628641' AS MILLI
, TO_CHAR(TO_TIMESTAMP('1733122628641'::DOUBLE PRECISION / 1000), 'YYYY/MM/DD HH24:MI:SS.MS')
, TO_DATE('2024-12-01 20:12:56', 'YYYY-MM-DD HH24:MI:SS')
, TO_TIMESTAMP('2024-12-01 20:12:56', 'YYYY-MM-DD HH24:MI:SS')
, TO_TIMESTAMP('2024-12-01 20:12:56', 'YYYY-MM-DD HH24:MI:SS')::DATE
;
날짜함수
SELECT
-- 특정해의 첫째날 : 2024-01-01 00:00:00.000 +0900
'2024-01-01'::TIMESTAMPTZ AS TIMESTAMP_01
, TO_TIMESTAMP('2024-01-01', 'YYYY-MM-DD') AS TIMESTAMP_02
, (TO_CHAR(NOW(), 'YYYY') || '-01-01')::TIMESTAMPTZ AS TIMESTAMP_03
, DATE_TRUNC('YEAR', NOW()) AS TIMESTAMP_04
-- 올해 : 2024
, EXTRACT(YEAR FROM NOW()) AS YEAR_01
, DATE_PART('YEAR', NOW()) AS YEAR_02
, TO_CHAR(NOW(), 'YYYY') AS YEAR_03
--작년 : 2023
, EXTRACT(YEAR FROM NOW() - INTERVAL '1 YEARS') AS YEAR_04
, TO_CHAR(NOW() - INTERVAL '1 YEARS', 'YYYY') AS YEAR_05
;