Can I rely on that each year have 52 weeks....or rather
how could I easily find how many weeks a year has.
Can I rely on year having 52 weeks
Moderator: General Moderators
Actually it seems to be more complex than that.
1998 for example has 53 weeks.
Well I am using this SQL query
btw using mysql 3.23.58
to get some data for a week.
But this year for example....01.01 is Sunday....
and it is in 52week from 2005
not 01 week from 2006...and apperantly the query is not getting it.
so I am thinking how could I get this date still using
WEEK and YEAR functions in the query.
1998 for example has 53 weeks.
Well I am using this SQL query
btw using mysql 3.23.58
Code: Select all
...
WHERE
WEEK (date,1) = 52
YEAR (date) = 2005
...But this year for example....01.01 is Sunday....
and it is in 52week from 2005
not 01 week from 2006...and apperantly the query is not getting it.
so I am thinking how could I get this date still using
WEEK and YEAR functions in the query.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Years only vary by one day every leap year. You never gain a full week.jmut wrote:Actually it seems to be more complex than that.
1998 for example has 53 weeks.
Well I am using this SQL query
btw using mysql 3.23.58to get some data for a week.Code: Select all
... WHERE WEEK (date,1) = 52 YEAR (date) = 2005 ...
But this year for example....01.01 is Sunday....
and it is in 52week from 2005
not 01 week from 2006...and apperantly the query is not getting it.
so I am thinking how could I get this date still using
WEEK and YEAR functions in the query.
Normal year:
365 / 7 = 52.142857143
Leap year:
366 / 7 = 52.285714286
ISO 8601 defines the Week as always starting with Monday being Day 1 and finishing with Sunday being Day 7. Therefore, the days of a single ISO Week can be in two different Calendar Years; and, because a Calendar Year has one or two more than 52×7 days, an ISO Year has either 52 or 53 Weeks.
The first Week of a Year is Number 01, which is :-
* defined as being the week which contains the first Thursday of the Calendar year; which implies that it is also :-
* the first week which is mostly within the Calendar year,
* the week containing January 4th,
* the week starting with the Monday nearest to January 1st.
The conditions are mutually equivalent. See Markus Kuhn and R.H. van Gent, via Date and Time Formats, for example.
The last Week of a Year, Number 52 or 53, therefore is :-
* the week which contains the last Thursday of the Calendar year;
* the last week which is mostly within the Calendar year;
* the week containing December 28th;
* the week ending with the Sunday nearest to December 31st.
Thus the ISO 8601 Week Numbers of a year are 01 to 52 or 53, which does not include zero. Part of Week 01 may be in the previous Calendar Year; part of Week 52 may be in the following Calendar Year; if a year has a Week 53, part of that week must be in the following Calendar Year. On average, six times out of seven, adjacent Dec 31st & Jan 1st are in the same Week.
For 53-Week ISO Years : January 1st and December 31st will usually both be Thursdays; but if the year is Leap then just one of them will be a Thursday.
February 29th is the last of the nine days of the year which always have the same ISO Week Number - I think.
A date in Week Number form should be written as yyyy-Www-d.
My week-cal.txt shows ISO Week Numbers for the calendar years 1970-2030.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
-
RobertPaul
- Forum Contributor
- Posts: 122
- Joined: Sun Sep 18, 2005 8:54 pm
- Location: OCNY
Code: Select all
date("W", mktime( 0, 0, 0, 12, 28, $year))So sayeth the ILoveJackDaniels.com PHP Cheat Sheet...