TO_DATE function is used to convert a string to an Oracle date type. It takes two parameters: the string expression to convert and a format mask specifying the string format. Common format masks include 'DD-MON-YY' (e.g. '12-JAN-23'), 'YYYY-MM-DD' (e.g. '2023-01-12') and 'HH24:MI:SS' (e.g. '12-JAN-23') For example '13:30:00'). Use a format mask to select the correct format to convert a string into a date value.
Usage of TO_DATE function in Oracle
TO_DATE function is used to convert a string to Oracle date type. It is useful for converting character data received from an external source, such as a file or web service, into a date value.
Syntax:
TO_DATE(string_expression, format_mask)
Parameters:
Format masks:
Oracle provides various format masks to specify the date format of string expressions. Here are some of the most commonly used masks:
Usage:
The usage of TO_DATE function is as follows:
Example:
The following example will convert '2023-01-12' to a date value:
SELECT TO_DATE('2023-01-12', 'YYYY-MM-DD') FROM dual;
The result will be a DATE Value: '2023-01-12'.
Note:
The above is the detailed content of Usage of todate function in oracle. For more information, please follow other related articles on the PHP Chinese website!