DATE AND TIME FUNCTION
1.SYSDATE
Returns the current date and time from the system.
Example - SELECT SYSDATE FROM dual;
SYSDATE
22-AUG-25
2.CURRENT_DATE
Returns the current date and time in the session time zone.
Example - SELECT CURRENT_DATE FROM dual;
CURRENT_DATE
22-AUG-25
3.SYSTIMESTAMP
Returns the current date and time including fractional seconds and time zone.
Example - SELECT SYSTIMESTAMP FROM dual;
SYSTIMESTAMP
22-AUG-25 12.45.48.289000 PM +05:30
4.TO_DATE
Converts a string to a date.
Example - SELECT TO_DATE('2025-08-22', 'YYYY-MM-DD') FROM dual;
TO_DATE('2025-08-22','YYYY-MM-DD')
22-AUG-25
5.TO_CHAR
Converts a date or timestamp to a string in a specified format.
Example - SELECT TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') FROM dual;
TO_CHAR(SYSDATE,'DD-MON-YYYYHH24:MI:SS')
22-AUG-2025 12:47:22
Page No.2 MAB
6.ADD_MONTHS
Adds a number of months to a date.
Syntax - ADD_MONTHS (date, number of months)
Example - SELECT ADD_MONTHS(SYSDATE, 3) FROM dual;
ADD_MONTHS(SYSDATE,3)
22-NOV-25
7. EXTRACT
Extracts part of a date (year, month, day, hour, etc.)
Example - SELECT EXTRACT(YEAR FROM SYSDATE) FROM dual;
EXTRACT(YEARFROMSYSDATE)
2025
8.LAST_DAY
Returns the last day of the month that contains the date.
Syntax – LAST_DAY(date)
Example- SELECT LAST_DAY('22/Aug/2025')FROM dual;
LAST_DAY('22/AUG/2025')
31-AUG-25
9. NEXT_DAY
Returns the date of the first day of the specified name that is later than the date
supplied.
Syntax – NEXT_DAY(date, day_name)
Example- SELECT NEXT_DAY('22/Aug/2025','TUESDAY') FROM dual;
NEXT_DAY('22/AUG/2025','TUESDAY')
26-AUG-25
Page No.2 MAB
Page No.2 MAB