Date Functions

Oracle has a number of functions that are used with dates. You have already seen the TO_CHAR function used to change the format of the date. Other functions exist to compute dates or to determine the months between dates. Table 7.3 lists the date functions.

The ADD_MONTHS Function

The ADD_MONTHS function is used to compute a new date based on a specified number of months. The function enables you to determine a more accurate date than simply adding a number of days to the target date. Errors can occur in date arithmetic if the computed date occurs in a year that is different from the target date. This function is better than straight arithmetic because it is not affected by leap years.

Table 7.3. Date Functions
Function Name ...

Get Oracle SQL and PL/SQL Handbook: A Guide for Data Administrators, Developers, and Business Analysts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.