반응형
/****************************************************************************************************************
-- Title : [PGS9.2] Date Type Formatting Function
-- Reference : www.postgresql.org
-- Key word : 날자 날짜 date type 데이터 타입 to_har
****************************************************************************************************************/

-- Formatting Functions
-- References : http://www.postgresql.org/docs/9.2/static/functions-formatting.html

Function Return Type Example
to_char(timestamp, text) text to_char(current_timestamp, 'HH12:MI:SS')
to_char(interval, text) text to_char(interval '15h 2m 12s', 'HH24:MI:SS')
to_char(int, text) text to_char(125, '999')
to_char(double precision, text) text to_char(125.8::real, '999D9')
to_char(numeric, text) text to_char(-125.8, '999D99S')
to_date(text, text) date to_date('05 Dec 2000', 'DD Mon YYYY')
to_number(text, text) numeric to_number('12,454.8-', '99G999D9S')
to_timestamp(text, text) timestamp with time zone to_timestamp('05 Dec 2000', 'DD Mon YYYY')
to_timestamp(double precision) timestamp with time zone to_timestamp(1284352323)

-- Sample
SELECT to_char(now(), 'YYYY-MM-DD HH24:MI:ss.ms');
SELECT to_char(now(), 'YYYYMMDD');

반응형

+ Recent posts