Pl/sql Type format Conversion _oracle

Source: Internet
Author: User
To_number (char[, ' Format_model ']) characters to numeric type
To_date (char[, ' Format_model ']) character conversion to date type
Format specifier: To be converted (match problem: format and number of digits) to the same format as the string to be converted.
To_char (date[, ' Format_model ' [, Nlsparams]])
The second argument can be omitted, without specifying a format, and output in the system default format.
Case sensitive.
Using FM (added before the format controller) can remove the space or the first 0.
If Nlsparams is specified, it controls the language in which the month and day components of the returned string are used. The format is:
' Nls_data_language=language ', LANGUAGE refers to the language needed.
Cases:
Select To_char (sysdate, ' Fmyyyy-mm-dd ') from dual;
Type of format control character:
YYYY Four-digit year
Year's spelling
MM 2-digit Month
Full name of MONTH month
MON the first three characters of the month name
DY the first three characters of the weekday name
The full name of day's weekday name
DD 2-bit of the day
Time Format Control character:
HH24:MI:SS AM
HH12:MI:SS PM
"" To implement a format control character that adds special characters.
SELECT to_char (sysdate, ' fmyyyy ' year "MM" month "DD" Day ") from dual;
Ddspth
~~
DD is a format control character.
Th is the ordinal number, which converts the date into the English ordinal spelling.
The SP is the cardinal Word and converts the date to the cardinal word spelling in English.
To_char (num[, ' Format_model ' [, Nlsparams]]) convert numbers
Converts the number type parameter num to the VARCHAR2 type. If you specify format, it controls the entire transformation.
If you do not specify a format, the resulting string will contain the same characters as the number of significant digits in Num. Nlsparams is used to specify decimal and thousand and currency symbols. Its format can be: ' nls_numeric_chars= ' ' dg ' nls_currency= ' string '
D and G represent decimal points and thousand characters respectively. A string represents a currency symbol.
Number format control characters:
9 represents a digit number (a replacement character). There is, the number shows; Not everything is shown. )
0 represents a digit (number, display; No, force show 0.) )
$ dollar Sign
L Local currency
. Decimal point
, the Thousand-character
B when the integer part is 0 o'clock, fill the integer part as a space. Example: B999
MI returns a negative value with a successor symbol instead of a leading minus sign, and a positive value with a subsequent space. 999MI
S returns a leading or successor symbol with a positive number of + and a negative number of-. S9999 or 9999S
PR uses angle brackets to return negative numbers. Positive numbers will have leading or subsequent spaces. 999PR
D returns a decimal point at the specified position. The number of 9 on both sides specifies the maximum number of digits. 99d9
G returns the Format_model at the specified position, and g can appear multiple times in the. 9g999g9
C returns the ISO currency symbol at the specified location. C can occur more than once in Format_model. C99
L returns the local currency symbol at the specified position. L99
V Returns a number that is multiplied by the N-second side of 10, where n is the number of 9 behind v. 99v99
EEEE uses scientific notation to return the value. 9.99EEEE
RM returns this value using uppercase Roman numerals. Rm
RM returns the value using a lowercase roman numeral representation. Rm
FM returns a value that does not contain leading and subsequent spaces. FM99.09
The number of format control characters must be greater than or equal to the number of digits, not less than.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.