There are three ways to enter the DATE type in Oracle: direct input, using the TO_DATE function and using the CAST function. Direct input must follow the YYYY-MM-DD HH24:MI:SS format; the TO_DATE function syntax is TO_DATE(string, formatted string); the CAST function syntax is CAST(string AS DATE).
How to enter the DATE type in Oracle
Input directly
The most direct way is to use the following syntax:
<code>DATE '格式化日期和时间'</code>
The date and time must be formatted according to a specific format, as follows:
<code>YYYY-MM-DD HH24:MI:SS</code>
For example:
<code>DATE '2023-03-08 14:30:00'</code>
Use the TO_DATE function
TO_DATE function converts the string to the DATE type. The syntax is as follows:
<code>TO_DATE(字符串, 格式化字符串)</code>
For example:
<code>TO_DATE('08-03-2023', 'DD-MM-YYYY')</code>
Use the CAST function
The CAST function can also convert a string to a DATE type. The syntax is as follows:
<code>CAST(字符串 AS DATE)</code>
For example:
<code>CAST('2023-03-08 14:30:00' AS DATE)</code>
Other notes
The above is the detailed content of How to enter date type in oracle. For more information, please follow other related articles on the PHP Chinese website!