Solved

MYSQL select records for a specific day from date column

Posted on 2009-05-09
3
474 Views
Last Modified: 2012-08-13
I have a table in mysql with a day column with type DATE.
I need to select all the records for Monday. Is there any way to filter records by putting
the day condition on date column. e.g.

select * from mytable where day = SomeTranslationFunction('Sunday');


select * from mytable where day = SomeTranslationFunction('Sunday');

Open in new window

0
Comment
Question by:SimonHowald
3 Comments
 
LVL 25

Accepted Solution

by:
lwadwell earned 500 total points
ID: 24343090
Hi SimonHowald,

try ...

select * from mytable where dayofweek(day) = 2;

the dayofweek() function returns the day of the week as 1 = Sunday, 2 = Monday ...

You could also use the dayname() function.


lwadwell
0
 
LVL 3

Expert Comment

by:khr2003
ID: 24343297
hi
I do not think there is a problem in adding a function to the query, however you must take into account the output of that function. So you have to be aware of the function you are using.

regards
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes some very basic things about SQL Server filegroups.
Read about achieving the basic levels of HRIS security in the workplace.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now