7. Handling Dates: Step 1

Demo

Extracting parts of dates

SQL

SELECT year(hiredate), month(hiredate), dayofmonth(hiredate) FROM emp;

Output

year(hiredate) month(hiredate) dayofmonth(hiredate)
1993 6 13
1998 8 15
1996 3 26
1995 10 31
1998 12 5
1992 6 11
1993 5 14
1996 3 5
1990 6 9
1995 6 4
1999 6 4
2000 6 23
1997 12 5
2000 1 21

Discussion

[Access] SELECT datepart('yyyy',hiredate),datepart('m',hiredate), datepart('d',hiredate) FROM emp;

[Oracle] SELECT EXTRACT(YEAR FROM hiredate), EXTRACT(MONTH FROM hiredate), EXTRACT(DAY FROM hiredate) FROM emp;

Progress

Proceed to Next step