SELECT * FROM `table_anw` WHERE DAYOFWEEK(datum) = 3; SELECT * FROM `table_anw` WHERE WEEKDAY(datum) = 2; SELECT * FROM `table_anw` WHERE DAYNAME(datum) = 'Tuesday'; SELECT * FROM `table_anw` WHERE DATE_FORMAT(datum,'%W') = 'Tuesday'; SELECT * FROM `table_anw` WHERE DATE_FORMAT(datum,'%a') = 'Tue';
DAYOFWEEK function begins back (1 for Sunday, 2 for Monday, ..., 7 for Saturday) (See http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_dayofweek) WEEKDAY function begins back (0 for Sunday, 1 for Monday, ..., 6 for Saturday) (See http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_weekday) DAYNAME brings back day of week fully spelled out (Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday) (See http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_dayname) DATE_FORMAT using special metacharacters for date and time components (see http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format) These queries should all bring back the same results where datum is a Tuesday Give it a try !!! Rolando A. Edwards MySQL DBA (CMDBA) 155 Avenue of the Americas, Fifth Floor New York, NY 10013 212-625-5307 (Work) 201-660-3221 (Cell) AIM & Skype : RolandoLogicWorx redwa...@logicworks.net http://www.linkedin.com/in/rolandoedwards -----Original Message----- From: Kerstin Finke [mailto:kerstinfi...@hotmail.com] Sent: Tuesday, September 29, 2009 9:04 AM To: mysql@lists.mysql.com Subject: SELECT by day Hi, I want to search all rows with datum = 'tuesday' for example, something like: SELECT * FROM `table_anw` WHERE datum=DAYOFWEEK(3); '3' as tuesday. I found in the manual I can do: SELECT DAYOFWEEK('1998-02-03'); and will get '3' for Tuesday. But thats not what I want. I want to select only tuesdays. Any ideas? Thanks in advance Kerstin -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=redwa...@logicworks.net -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=arch...@jab.org