7. Handling Dates: Step 4

Demo

To compute dates.

To list the employees with their 5 year service dates:

SQL

SELECT ename, date_add(hiredate,interval 5 year) FROM emp ;

Output

ename date_add(hiredate,interval 5 year)
SMITH 1998-06-13
ALLEN 2003-08-15
WARD 2001-03-26
JONES 2000-10-31
MARTIN 2003-12-05
BLAKE 1997-06-11
CLARK 1998-05-14
SCOTT 2001-03-05
KING 1995-06-09
TURNER 2000-06-04
ADAMS 2004-06-04
JAMES 2005-06-23
FORD 2002-12-05
MILLER 2005-01-21

Discussion

[Access] SELECT ename, hiredate+5*365 FROM emp ;

[Oracle] SELECT ename,add_months(hiredate,5*12) FROM emp;

Progress

Proceed to Next step