WEEKDAY(): weekday number from 0 to 6 mysql function

Returns the Day number of the weekday from a date in the range 0 ( Monday ) to 6 ( Sunday ) .
Syntax
WEEKDAY(date)
Example
SELECT WEEKDAY('2016-09-21')
Output is 2
  • Video Tutorial on Date function WEEKDAY()


Using CURDATE()

SELECT WEEKDAY(CURDATE())
This will return weekday in number of present ( today's ) date.

CURDATE()

For a invalid date we will get Null as output
SELECT WEEKDAY('2015-02-31')
Output is NULL
DEMO: Select date from Calendar to execute WEEKDAY()
Output of WEEKDAY() function is from 0 to 6,
0 for Monday, 1 for Tuesday .... 6 for Sunday

Yesterday today and tomorrow WEEKDAY()

This query will return WEEKDAY() number of yesterday , today and tomorrow
SELECT WEEKDAY(CURDATE()- INTERVAL 1 DAY) as yesterday,
WEEKDAY(CURDATE()) as today,
WEEKDAY(CURDATE()+ INTERVAL 1 DAY) as tomorrow;

SQL Date WEEK() : Week Number in Year( 0 to 53 ) DAYOFWEEK() : Weekday Number from 1 to 7
SQL txt file for WEEKDAY()


plus2net.com






Post your comments , suggestion , error , requirements etc here





SQL Video Tutorials










We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer