DAYNAME( ) is useful in conjunction with other date-related techniques. : DAYNAME « Date Time « SQL / MySQL






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

1.Return the name of the day: DAYNAME()
2.Treating date-and-time as Numbers
3.Finding the Day of the Week for a Date
4.DAYNAME( ) returns the complete day name.
5.Get the name of the day
6.DayName returns Monday, Tuesday ...
7.Use DAYNAME( ) to display weekday names instead.