Name
WEEKDAY()
Synopsis
WEEKDAY(date
)
This function returns the number for the day of the week. Monday is considered the first day of the week for this function and returns a value of 0; a Sunday returns 6. Here is an example:
SELECT appt_id, client_id FROM appointments WHERE WEEKDAY(appt) > 4 AND EXTRACT(YEAR_MONTH FROM appt) = EXTRACT(YEAR_MONTH FROM NOW( ));
This SQL statement, based on the WHERE
clause, retrieves a list of appointments that are on the weekends of
the current month.
Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.