Using Functions to Format Date and Time Values
We live in a civilization governed by times and dates, and most major implementations of SQL have functions to cope with these concepts. This section uses the table PROJECT to demonstrate the time and date functions.
SQL> SELECT * FROM PROJECT;
TASK STARTDATE ENDDATE
--------------- --------- ---------
KICKOFF MTG 01-APR-95 01-APR-95
TECH SURVEY 02-APR-95 01-MAY-95
USER MTGS 15-MAY-95 30-MAY-95
DESIGN WIDGET 01-JUN-95 30-JUN-95
CODE WIDGET 01-JUL-95 02-SEP-95
TESTING 03-SEP-95 17-JAN-96
6 rows selected.
The MySQL equivalent is
mysql> select * from project; +---------------+------------+------------+ | task | startdate | enddate | +---------------+------------+------------+ | KICKOFF MTG | 1998-04-01 ...
Get Sams Teach Yourself SQL in 21 Days, Fourth Edition 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.