Oracle

Date Format

damian 2013. 8. 13. 10:08

 

alter session set nls_date_language='english'
;

 

alter session set nls_date_language='korean'
;

 

-- nls_date_language 의 영향을 받지 않음

select to_date('Apr 20 2010 12:35:06 PM','MON DD YYYY HH:MI:SS AM')
 from dual
 ;

 

-- nls_date_language='english' 인 경우

select to_timestamp('Apr 20 2010 12:35:06:030 PM','MON DD YYYY HH:MI:SS:FF3 AM')
 from dual
 ;

 

-- nls_date_language 값에 따라 결과가 다름

select to_char(systimestamp,'MON DD YYYY HH:MI:SS:FF AM')
 from dual
 ;

 

-- nls_date_language='korean' 인 경우

8월  13 2013 02:08:38:061000 오후

 

-- nls_date_language='english' 인 경우

AUG 13 2013 02:08:51:103000 PM


Format mask

Description
CC Century
SCCCentury BC prefixed with -
YYYY Year with 4 numbers
SYYY Year BC prefixed with -
IYYY ISO Year with 4 numbers
YY Year with 2 numbers
RR Year with 2 numbers with Y2k compatibility
YEAR Year in characters
SYEAR Year in characters, BC prefixed with -
BC BC/AD Indicator *
Q Quarter in numbers (1,2,3,4)
MM Month of year 01, 02...12
MONTH Month in characters (i.e. January)
MON JAN, FEB
WW Weeknumber (i.e. 1)
W Weeknumber of the month (i.e. 5)
IW Weeknumber of the year in ISO standard.
DDDDay of year in numbers (i.e. 365)
DD Day of the month in numbers (i.e. 28)
D Day of week in numbers(i.e. 7)
DAY Day of the week in characters (i.e. Monday)
FMDAYDay of the week in characters (i.e. Monday)
DY Day of the week in short character description (i.e. SUN)
J Julian Day (number of days since January 1 4713 BC, where January 1 4713 BC is 1 in Oracle)
HH Hournumber of the day (1-12)
HH12 Hournumber of the day (1-12)
HH24 Hournumber of the day with 24Hours notation (1-24)
AM AM or PM
PM AM or PM
MI Number of minutes (i.e. 59)
SS Number of seconds (i.e. 59)
SSSSS Number of seconds this day.
DS Short date format. Depends on NLS-settings. Use only with timestamp.
DLLong date format. Depends on NLS-settings. Use only with timestamp.
E Abbreviated era name. Valid only for calendars: Japanese Imperial, ROC Official and Thai Buddha.. (Input-only)
EE The full era name
FF The fractional seconds. Use with timestamp.
FF1..FF9 The fractional seconds. Use with timestamp. The digit controls the number of decimal digits used for fractional seconds.
FM Fill Mode: suppresses blianks in output from conversion
FX Format Exact: requires exact pattern matching between data and format model.
IYY or IY or I the last 3,2,1 digits of the ISO standard year. Output only
RM The Roman numeral representation of the month (I .. XII)
RR The last 2 digits of the year.
RRRRThe last 2 digits of the year when used for output. Accepts fout-digit years when used for input.
SCC Century. BC dates are prefixed with a minus.
CC Century
SP Spelled format. Can appear of the end of a number element. The result is always in english. For example month 10 in format MMSP returns "ten"
SPTH Spelled and ordinal format; 1 results in first.
TH Converts a number to it's ordinal format. For example 1 becoms 1st.
TS Short time format. Depends on NLS-settings. Use only with timestamp.
TZD Abbreviated time zone name. ie PST.
TZH Time zone hour displacement.
TZM Time zone minute displacement.
TZR Time zone region
X Local radix character. In america this is a period (.)

 


'Oracle' 카테고리의 다른 글

필드 숫자 여부 확인 (isnumber)  (0) 2013.09.13
PK, Index 조회  (0) 2013.09.10
ORA-04031 오류로 인한 DB 접속 불가시 처리 방법  (0) 2013.07.29
PL/SQL CURSOR 예제  (0) 2013.04.24
Oracle 관련 링크  (0) 2013.03.07