Oracle DATE Format

ดูเวลาใน Oracle
select sysdate from dual;

TO_CHAR :

1
TO_CHAR(<date>, '<format>')

To_DATE :

1
TO_DATE(<string>, '<format>')

DATE Format

1
2
3
4
5
6
7
8
9
10
11
12
13
MM : Numeric month (e.g., 07)
MON : Abbreviated month name (e.g., JUL)
MONTH : Full month name (e.g., JULY)
DD : Day of month (e.g., 24)
DY : Abbreviated name of day (e.g., FRI)
YYYY : 4-digit year (e.g., 1998)
YY : Last 2 digits of the year (e.g., 98)
RR : Like YY, but the two digits are ``rounded'' to a year in the range 1950 to 2049. Thus, 06 is considered 2006 instead of 1906
AM (or PM) : Meridian indicator
HH : Hour of day (1-12)
HH24 : Hour of day (0-23)
MI : Minute (0-59)
SS : Second (0-59)

The Current Time

1
select to_char(sysdate, 'Dy DD-Mon-YYYY HH24:MI:SS') as "Current Time" from dual;

เอามาเก็บไว้จะได้ไม่ต้อง research อีก ชอบสับสนระหว่าง format ของ Data ใน Java กับ ของ SQL

Comments are closed.