Serial number |
Format |
Simple example |
Description |
1 |
- / , . ; : |
Slightly |
The time separator symbol, in addition to the standard several, also allows the use of text as a segmentation symbol. |
"Text" |
For example To_char (sysdate, ' YYYY ' year "MM" month "DD" day ") = April 24, 2008 |
2 |
AD |
|
That is, the Latin anno Domini, the abbreviation for the ad. will be converted to AD, etc. according to the different NLS |
A.D. |
No special precautions |
3 |
Am |
|
Morning shorthand, same as PM, P.M. (PM), Chinese environment output is morning (if it is morning) |
a.m.. |
4 |
Bc |
|
Although the standard notation is B.C. (c lowercase) or BC, fortunately Oracle does not pay attention to this. means BC |
B.C. |
5 |
Cc |
|
Returned to the century, expressed in Arabic numerals |
Scc |
If the last two bits of the year are between 01-99 then, return the first two bits +1, otherwise return the first two digits |
6 |
D |
|
One day of the week, the return is ordinal 1-7 |
7 |
Day |
|
One of the days of the week, but the return of the day of the week, which is related to language settings, in the Chinese environment nls_date_language=simplified Chinese, from Monday to Sunday expressed |
8 |
Dd |
|
Day of the Month (1-31) |
9 |
Ddd |
|
One day in the year (1-366) |
10 |
Dl |
' DL ' |
Returns a long date format. Controlled by the Nls_territory,nls_language parameter. Example Monday, April 28, 2008 |
Limitations: Other than DL, nothing else can be set. |
11 |
Ds |
|
Returns the short date format. Controlled by the Nls_territory,nls_language parameter. For example 2008-04-28 |
Limitations: Other than DL, nothing else can be set. |
12 |
Dy |
|
The abbreviation of the date is the day of the week (of course this refers to the Chinese environment) |
13 |
E |
|
The era abbreviation, but only suitable for the following centralized calendar: Japanese royal family, Republic of China, too Buddhist calendar |
14 |
Ee |
|
The whole era, suitable for the situation with E |
15 |
FF [1..9] |
|
Is the millisecond, if not the number is the default precision. |
Can only be used with timestamp types. |
16 |
Fm |
|
One of the notable functions: no content is returned. |
I'm not sure why Oracle set this thing up. |
17 |
Fx |
|
Ditto |
18 |
HH |
|
Represents hours, 12-hour, with Hh12 (1-12) |
19 |
HH12 |
|
Represents hours, 12-hour (1-12) |
20 |
HH24 |
|
Represents hours, 24-hour (0-23) |
21st |
IW |
|
ISO Standard week serial number (1-52, or 1-53) |
22 |
Iyyy |
|
Iyy,iy,i, ISO year (4-bit) 4,3,2,1 digits (reciprocal) |
Iyy |
To_char (To_date (21120401, ' yyyymmdd '), ' iyyy, iyy,iy,i ') = 2112, 112,12,2 |
IY |
|
I |
|
23 |
J |
|
Julian Day (more than one calendar for astronomy), from January 1, 4712 BC, the result is an integer, the algorithm is generally (A.D. date +4712) * Julian calendar average number of days |
24 |
MI |
|
Seconds (0-59) |
25 |
Mm |
|
2-month (1-12) |
26 |
MON |
|
The abbreviation of the month, and the national related department nls_date_language, for example 04 in Chinese environment with April expressed. |
27 |
MONTH |
|
The name of the month, the state related department Nls_date_language, currently in Chinese under 04 is expressed as April. |
28 |
Pm |
|
The same am,a.m that afternoon. |
the p.m.. |
29 |
Q |
|
Quarter (1-4) |
30 |
Rm |
|
Month in Roman numerals, I, II, III, IV, V, VI, VII, Viii,ix, X, XI, XII |
31 |
Rr |
|
A little rounding represents the meaning of the year, and the specific usage is a little bit more complicated. |
The last two bits of the year entered in S, C represents the last two bits of the current year, and the output (the new first two bits of the year) can be represented by the function r=f (s,c), which S2,C2 represents the first two bits of s,c respectively. |
1) s=[0,49],c=[0,49], then R=C2 |
2) s=[0,49],c=[50,99], then r=c2+1 |
3) s=[50,99],c=[0,49], then r=c2-1 |
4) s=[50,99],c=[50,99], then R=C2 |
In short, it is close to the current year principle, if it is the same as the current year, if it is larger than the current one, then it is considered to be the current century ago First century, otherwise it is the next century. |
For example, take to_date as an example |
Sql> Select To_date (' 89-01-01 ', ' rr-mm-dd '), to_date (' 12-01-01 ', ' rr-mm-dd ') from DUAL; |
|
To_date (' 89-01-01 ', ' Rr-mm-dd ') to_date (' 12-01-01 ', ' rr-mm-dd ') |
------------------------------ ------------------------------ |
1989-01-01 2012-01-01 |
I think Oracle is going to get this stuff out, and it's estimated that two of them are for convenience and one is to deal with a century or a thousand-year problem. |
32 |
RRRR |
|
If the input parameter is only two bits, then the same RR, otherwise the same yyyy effect. |
33 |
Ss |
|
Seconds (0-59), within one minute |
34 |
Sssss |
|
The cumulative number of seconds from midnight of the day. (0-86399) |
35 |
Ts |
|
Returns the short date format content, including seconds, minutes, and so on, can only be used in combination with DL,DS, the format is: |
DL ts or DL ts, separated by a space interval. To_char (sysdate, ' TS ') = 4:50:04 |
The expressions are influenced by nls_territory and Nls_language. |
36 |
TZD |
|
Daylight saving time information, timezone shorthand plus daylight saving time information, must correspond to the timezone set in format TZR. |
Including the following three TZ start, are related to the time zone, not directly used in To_char |
37 |
TZH |
|
Hours in a time zone, such as Hh:mi:ss.fftzh:tzm ' |
38 |
TZM |
|
The minutes in the time zone. |
39 |
TZR |
|
Region information in the time zone, which must be the time zone supported by the database, such as Us/pacific |
40 |
Ww |
|
Similar to IW, it also represents the ordinal of a week, from the first day of the year to the last seventh day of the year. The values are basically the same. (1-53), for example, 2008-01-01 to 2008-01-07 Count 1,2008-01-09~2008-01-13 2 |
41 |
W |
|
One months of the week ordinal, the algorithm with WW, but confined to the January only, and ISO differences. |
42 |
X |
|
Represents the local root symbol, which is not particularly useful and can only be used with the timestamp type. |
43 |
Y,yyy |
|
Four-bit years, separated by good example 2,008 |
44 |
Year |
|
Year of articulation, e.g. 2008=two thousand eight |
Syear |
s prefix means BC BC |
45 |
YYYY |
|
Four-digit year, s-prefix denotes BC |
Syyyy |
46 |
YYY |
|
A year that represents the 3,2,1 bit in the back, for example, 2008 can be evaluated as 008,08,8 |
Yy |
Y |
|
Summarize |
|
From the above, the main expression is the format of several parts of the time: Century, year, month, day, hour, minute, second, millisecond, and some other mixed format. Each time part can have a variety of expressions, through this classification is more easily remembered. |
Many formats can be used together, which can eventually form a sufficiently rich expression of their situation; |
Second, many formats and NLS are closely related, and finally some output (return) and the format of the case is related, this is not reflected in the Chinese environment (currently not seen), but the English environment under the name of To_char (sysdate, ' Day ') as an example, If the western environment is to return sun (assuming Sysdate is on the weekends), if To_char (sysdate, ' Day ') returns to Sun |