DAYNAME( ) is useful in conjunction with other date-related techniques.
mysql>
mysql>
mysql> SET @d = CURDATE( );
Query OK, 0 rows affected (0.00 sec)
mysql> SET @first = DATE_SUB(@d,INTERVAL DAYOFMONTH(@d)-1 DAY);
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT @d AS 'starting date',
-> @first AS '1st of month date',
-> DAYNAME(@first) AS '1st of month day';
+---------------+-------------------+------------------+
| starting date | 1st of month date | 1st of month day |
+---------------+-------------------+------------------+
| 2011-10-03 | 2011-10-01 | Saturday |
+---------------+-------------------+------------------+
1 row in set (0.00 sec)
Related examples in the same category