Mega Code Archive

 
Categories / MySQL / Date Time
 

Get the name of the day

mysql> mysql> CREATE TABLE IF NOT EXISTS labor_day     -> (     ->   id     INT     AUTO_INCREMENT PRIMARY KEY,     ->   date   DATETIME NOT NULL     -> ); Query OK, 0 rows affected (0.00 sec) mysql> mysql> INSERT INTO labor_day (date) VALUES ("2005-09-05 12:45:30"); Query OK, 1 row affected (0.00 sec) mysql> mysql> # get the name of the day mysql> SELECT DAYNAME(date) FROM labor_day; +---------------+ | DAYNAME(date) | +---------------+ | Monday        | +---------------+ 1 row in set (0.00 sec) mysql> mysql> # delete this sample table mysql> DROP TABLE IF EXISTS labor_day; Query OK, 0 rows affected (0.00 sec) mysql>