Alex Rivera | Logout

Select day of week from date

Asked 2011-05-11T16:16:30.147
27

I have the following table in MySQL that records event counts of stuff happening each day

event_date     event_count
2011-05-03     21
2011-05-04     12
2011-05-05     12

I want to be able to query this efficiently by date range AND by day of week. For example - "What is the event_count on Tuesdays in May?"

Currently the event_date field is a date type. Are there any functions in MySQL that let me query this column by day of week, or should I add another column to the table to store the day of week?

The table will hold hundreds of thousands of rows, so given a choice I'll choose the most efficient solution (as opposed to most simple).

Edit
Report

1 Answer

4

Check DAYOFWEEK() function

answered 2011-05-11T16:22:33.803

Your Answer