The function in Oracle that converts a string to a date is TO_DATE. The syntax is TO_DATE(string, format_mask), where format_mask specifies the format of the date part in the string. Common formats include YYYY (year), MM (month), DD (date), HH (hour), MI (minute), SS (seconds) and FF (milliseconds). If the string does not conform to the specified format, the function returns NULL.
Function to convert string to date in Oracle
Function to convert string to date in Oracle is TO_DATE
.
Syntax
##TO_DATE(string, format_mask)
: The string to be converted
: The mask that specifies the format of the date part in the string
Usage example
The following example converts the string "2023-03-08" to a date:<code class="sql">SELECT TO_DATE('2023-03-08', 'YYYY-MM-DD') FROM dual;</code>
<code>08-MAR-23</code>
Mask format
format_mask Mask specifies the format of the date portion of the string. The following are common mask formats:
: year (four digits)
: year (two digits) )
: Month (two digits)
: Date (two digits)
: Hours (two digits)
: Minutes (two digits)
: Seconds (two digits) )
: milliseconds (three digits)
Note
function will return
NULL.
The above is the detailed content of What is the function to convert string to date in Oracle?. For more information, please follow other related articles on the PHP Chinese website!