In Oracle, you can use the TO_DATE function to convert a string into date format, the syntax is TO_DATE(string_expression, format_mask). format_mask is used to specify the format of the date and time part in the string. Common format mask characters include: YYYY (year), MM (month), DD (day), HH24 (hour), MI (minute) and SS (second) ). For example, the query to convert "2023-03-21 17:30:15" to a date is: SELECT TO_DATE('2023-03-21 17:30:15', 'YYYY
Oracle string to date function
In Oracle, converting a string to date format can be achieved through the TO_DATE
function.
## Syntax:
<code class="sql">TO_DATE ( string_expression, format_mask )</code>
Parameters:
The format mask specifies the date and time parts using the following characters:
Convert the string "2023-03-21 17:30:15" to date:
<code class="sql">SELECT TO_DATE('2023-03-21 17:30:15', 'YYYY-MM-DD HH24:MI:SS') FROM dual;</code>
<code>2023-03-21 17:30:15.000000</code>
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!