WEEK(): function in a MySQL date and time field

Returns the week number of the year from a date .
SELECT WEEK('2015-07-25')
Output is 29
For a invalid date we will get Null as output
SELECT WEEK('2015-02-31')
Output is NULL

Understanding Mode (Optional Parameter , value 0 to 7)

The week can start on Sunday or Monday,
The week of 1st of Jan should have 4 more days to qualify for week No. 1
Otherwise it will be last week of previous year and next week will be No. 1
In the DEMO page for WEEK() try these days to understand the concepts of Mode.

2012-01-01 change the First Day of Week to Monday
2018-01-01 select Sunday as First Day of Week
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net


    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-2023 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer