CREATE TABLE people( id INT AUTO_INCREMENT PRIMARY KEY, first_name VARCHAR(50) NOT NULL, last_name VARCHAR(50) NOT NULL, birth_date DATE NOT NULL );
INSERT INTO people(first_name,last_name,birth_date) VALUES('John','Doe','1990-09-01');
SELECT first_name, last_name, birth_date FROM people;
INSERT INTO people(first_name,last_name,birth_date) VALUES('Jack','Daniel','01-09-01'), ('Lily','Bush','80-09-01');
SELECT first_name, last_name, birth_date FROM people;
SELECT DATEDIFF('2015-11-04','2014-11-04') days;
SELECT NOW();
SELECT DATE(NOW());
SELECT CURDATE();
SELECT DATE_FORMAT(CURDATE(), '%m/%d/%Y');
SELECT '2015-01-01', DATE_ADD('2015-01-01', INTERVAL 1 DAY) 'one day later', DATE_ADD('2015-01-01', INTERVAL 1 WEEK) 'one week later', DATE_ADD('2015-01-01', INTERVAL 1 MONTH) 'one month later', DATE_ADD('2015-01-01', INTERVAL 1 YEAR) 'one year later';
SELECT '2015-01-01', DATE_SUB('2015-01-01', INTERVAL 1 DAY) 'one day before', DATE_SUB('2015-01-01', INTERVAL 1 WEEK) 'one week before', DATE_SUB('2015-01-01', INTERVAL 1 MONTH) 'one month before', DATE_SUB('2015-01-01', INTERVAL 1 YEAR) 'one year before';
SELECT DAY('2000-12-31') day, MONTH('2000-12-31') month, QUARTER('2000-12-31') quarter, YEAR('2000-12-31') year;
SELECT WEEKDAY('2000-12-31'), WEEK('2000-12-31'), WEEKOFYEAR('2000-12-31');
SELECT WEEKDAY('2000-12-31'), WEEK('2000-12-31',1), WEEKOFYEAR('2000-12-31');