Date in Oracle 23ai (26ai), ora-01830 #211594
🏷️ Discussion TypeQuestion BodyHi, The default view should be just the date Guidelines
|
Replies: 2 comments 5 replies
|
An Oracle I tested this on Oracle 23ai Free:
To show only the date, use one of these: SELECT TO_CHAR(start_date, 'YYYY-MM-DD') FROM table1;ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD';To store the date with the time set to midnight, use |
|
Hi, In Oracle, the There are two different solutions, depending on your requirements. 1. Display only the date If you want to display the date in SELECT TO_CHAR(start_date, 'YYYY-MM-DD') AS start_date
FROM table1;This returns a formatted string rather than an Oracle 2. Remove the time component when inserting If you want to store the date with the time set to midnight, use INSERT INTO table1 (start_date)
SELECT TRUNC(start_date)
FROM table2;This preserves the date while setting the time to 3. Change the display format for your session If you want Oracle to display dates without the time component by default in your current session, you can use: ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD';Note that this changes the default display format for the session, not the stored data or the underlying Why are you getting those errors?
The exact cause depends on the expression you used. Avoid applying Recommendation: If your only concern is how the result appears when queried, start with For more details, see the [Oracle SQL Language Reference — Data Types](https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html). |
In my test,
TO_CHAR(start_date, 'YYYY-MM-DD')worked on aDATEcolumn. I got ORA-01722 only on aVARCHAR2column.Please post the output of
DESC table1and your full query. Maybe the query readstable2or a view.