Thursday, October 23, 2008

Date and Time related Functions

ADD_MONTHS returns the date adding given integer months to the date.The return type is always DATE.

CURRENT_DATE returns the current date in the session time zone.

CURRENT_TIMESTAMP returns the current date and time in the session time zone.The time zone offset reflects the current local time of the SQL session.

MONTHS_BETWEEN returns number of months between 2 dates date1 and date2. If date1 is later than date2, then the result is positive. If date1 is earlier than date2, then the result is negative.

NEXT_DAY returns the date of the first weekday named by char that is later than the date date. The return type is always DATE.
EX:SELECT NEXT_DAY('02-APR-2001','FRIDAY') FROM DUAL;Output is 09-APR-2001.
Above example returns the date of the next friday after April 2, 2001.

SYSDATE returns the current date and time set for the operating system on which the database resides.

No comments:

Post a Comment

Disclaimer