Table shows the DAYOFWEEK( ) expressions to use for putting any day of the week first in the sort order : DAYOFWEEK « Date Time « SQL / MySQL






Table shows the DAYOFWEEK( ) expressions to use for putting any day of the week first in the sort order

     

Day to list first                 DAYOFWEEK( ) expression
Sunday                            DAYOFWEEK(date)
Monday                            MOD(DAYOFWEEK(date) + 5, 7)
Tuesday                           MOD(DAYOFWEEK(date) + 4, 7)
Wednesday                         MOD(DAYOFWEEK(date) + 3, 7)
Thursday                          MOD(DAYOFWEEK(date) + 2, 7)
Friday                            MOD(DAYOFWEEK(date) + 1, 7)
Saturday                          MOD(DAYOFWEEK(date) + 0, 7)

   
    
    
    
    
  








Related examples in the same category

1.Return the day of the week by number: DAYOFWEEK()
2.DAYOFWEEK( ) returns values from 1 to 7, corresponding to Sunday through Saturday.
3.Sorting by Day of Week
4.To produce a day-of-week summary instead, use the DAYOFWEEK( ) function: