How can Oracle retrieve the current system date?
Oracle can use the SYSDATE function to retrieve the current system date, which returns a date value representing the current date and time.
Here are some examples of using the SYSDATE function to retrieve the current date in the system:
- Check the current system date:
SELECT SYSDATE FROM dual;
- Assign the current system date to a variable.
DECLARE
current_date DATE;
BEGIN
current_date := SYSDATE;
DBMS_OUTPUT.PUT_LINE('Current date is: ' || current_date);
END;
Please note that the SYSDATE function returns a date value. If you only need the date part, you can use the TRUNC function to truncate the time part.
SELECT TRUNC(SYSDATE) FROM dual;