List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:July 28 1999 8:16pm
Subject:Re: WEEK() function
View as plain text  
At 2:26 PM -0500 7/28/99, Steve Ruby wrote:
>The other ODBC WEEK() functions I am familiar with
>break weeks up as follows
>Weekstart = Sunday
>Weekend = Saturday
>January 1 to the first Sunday is Week 1
>It appears that the WEEK() function in MysQL
>may use
>WeekStart = Monday
>Weekend = Sunday
>If the Jan 1 is not Monday then jan 1 to
>the first Sunday is week 53.
>I believe this may be a difference in thinking
>between Europe and America as far as dates are
>Is there a way around this? If not is is possible
>to implement a variation on the WEEK() function
>that does it the other way?

You can pick the way you want.  From the manual:

@findex WEEK()
@item WEEK(date)
@itemx WEEK(date,first)
With a single argument, returns the week for @code{date}, in the range
@code{0} to @code{52}, for locations where Sunday is the first day of the week.
The two-argument form of @code{WEEK()} allows you to specify whether the
week starts on Sunday or Monday.  The week starts on Sunday if the second
argument is @code{0}, on Monday if the second argument is @code{1}.
mysql> select WEEK('1998-02-20');
        -> 7
mysql> select WEEK('1998-02-20',0);
        -> 7
mysql> select WEEK('1998-02-20',1);
        -> 8
@end example

Paul DuBois, paul@stripped
WEEK() functionSteve Ruby28 Jul
  • Re: WEEK() functionPaul DuBois29 Jul
    • Re: WEEK() functionSteve Ruby29 Jul
      • Re: WEEK() functionPaul DuBois29 Jul