Second Tuesday of the Month : Date Arithmetic « Date Timestamp Functions « Oracle PL/SQL Tutorial






SQL>
SQL> CREATE TABLE monthdates(monthdate date NOT NULL PRIMARY KEY);

Table created.

SQL> INSERT INTO monthdates(monthdate) VALUES (DATE '2007-04-01');

1 row created.

SQL> INSERT INTO monthdates(monthdate) VALUES (DATE '2007-05-01');

1 row created.

SQL> INSERT INTO monthdates(monthdate) VALUES (DATE '2007-06-01');

1 row created.

SQL>
SQL> SELECT monthdate    AS first_day_of_month
  2       , monthdate
  3            + MOD( ( 10 - TO_CHAR(monthdate,'d') ), 7 ) + 7
  4                      AS second_tuesday_of_month
  5    FROM monthdates
  6
SQL> DROP TABLE monthdates;

Table dropped.

SQL>








13.26.Date Arithmetic
13.26.1.Using Date Arithmetic
13.26.2.Subtracts two days from August 2, 2003
13.26.3.Subtract one date from another, yielding the number of days between the two dates.
13.26.4.select date '1996-01-29' + interval '1' month as col_1
13.26.5.select date '1997-08-11' - interval '3' month as col_3
13.26.6.Second Tuesday of the Month