The function in Oracle that converts a string into the DATE data type is the TO_DATE function. The usage is as follows: TO_DATE(string_expression, format_mask)string_expression: The string value to be converted. format_mask: A mask that specifies the format of the date/time component in a string.
Function to convert string to date in Oracle: TO_DATE
TO_DATE function converts string value to DATE data type. The syntax is as follows:
<code>TO_DATE(string_expression, format_mask)</code>
Parameters:
Usage:
When using the TO_DATE function to convert a string to the DATE type, you need to specify format_mask
to indicate the date in the string /The format of the time component. For example:
<code>TO_DATE('2023-01-01', 'YYYY-MM-DD')</code>
This will convert the string "2023-01-01" to the DATE type with the format "YYYY-MM-DD".
Common format masks:
Common date/time format masks in Oracle include:
Example:
<code>TO_DATE('2023-03-15', 'YYYY-MM-DD')</code>
<code>TO_DATE('12:30 PM', 'HH:MI AM')</code>
The above is the detailed content of Which function is used to convert string to date in Oracle?. For more information, please follow other related articles on the PHP Chinese website!