29.7. Weeks

Weeks are not part of the SQL temporal functions, but they are part of ISO-8601 Standards. While it is not as common in the United States as it is in Europe, many commercial and industrial applications use the week within a year as a unit of time.

Week 01 of a year is defined as the first week that has the Thursday in that year, which is equivalent to the week that contains the fourth day of January. In other words, the first week of a New Year is the week that has the majority of its days in the New Year. Week 01 might also contain days from the previous year, so it does not align with the years.

The standard notation uses the letter ‘W’ to announce that the following two digits are a week number. The week number component of the ...

Get Joe Celko's SQL for Smarties, 3rd 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.