SELECT TO_CHAR (SYSDATE, ‘YYYY-MM-DD HH24:MI:SS’) “Current_Date” FROM DUAL;
In Oracle, you can use the TO_CHAR
function to format the current date and time. The syntax to find the current date and time in the “YYYY-MM-DD” format is as follows:
SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD') FROM DUAL;
Here, SYSDATE
is a function that returns the current date and time, and TO_CHAR
is used to convert it to a specific date format, in this case, ‘YYYY-MM-DD’. The FROM DUAL
is used because a SELECT
statement in Oracle requires selecting from a table, and DUAL
is a one-row, one-column table often used for such purposes.