MySQL has other functions for returning just a part of a date: MONTH() and DAYOFMONTH(): : DAYOFMONTH « Date Time « SQL / MySQL






MySQL has other functions for returning just a part of a date: MONTH() and DAYOFMONTH():

    
mysql>
mysql> CREATE TABLE sales_rep(
    ->   employee_number INT,
    ->   surname VARCHAR(40),
    ->   first_name VARCHAR(30),
    ->   commission TINYINT,
    ->   date_joined date,
    ->   birthday date
    -> );
Query OK, 0 rows affected (0.01 sec)

mysql>
mysql> INSERT INTO sales_rep values(1,'James','Writer',10, '1989-01-01', '1969-02-02');
Query OK, 1 row affected (0.00 sec)

mysql>
mysql>
mysql>
mysql> SELECT MONTH(birthday),DAYOFMONTH(birthday) FROM sales_rep;
+-----------------+----------------------+
| MONTH(birthday) | DAYOFMONTH(birthday) |
+-----------------+----------------------+
|               2 |                    2 |
+-----------------+----------------------+
1 row in set (0.00 sec)

mysql>
mysql> drop table sales_rep;
Query OK, 0 rows affected (0.00 sec)

   
    
    
    
  








Related examples in the same category

1.Get the day, month and year date components