Gayan
Gayan

Reputation: 2935

MySQL Timestamp how to write a query to select weekdays only

I want to write mysql for filter weekday result only. I used timestamp for store dates. can anyone help me to this?

eg; SELECT * FROM mytable WHERE WEEKDAY('mydate_field')

Upvotes: 3

Views: 2597

Answers (3)

truesource
truesource

Reputation: 397

you can also try like this.

SELECT * FROM your_table WHERE WEEKDAY(mydate_field)>0 AND WEEKDAY(mydate_field)<6;   

Upvotes: 0

G one
G one

Reputation: 2729

Try something like this:

SELECT * FROM mytable
WHERE WEEKDAY('mydate_field')<5

Upvotes: 3

Vishwanath Dalvi
Vishwanath Dalvi

Reputation: 36601

Considering you mean excluding Sunday and Saturday.

SELECT * FROM mytable 
WHERE DAYOFWEEK('mydate_field') in (2,3,4,5,6)

Upvotes: 5

Related Questions