hi, i was solving same problem before month and i finished it by this way:

select dayname("2003-11-12"), yearweek("2003-11-12"),ADDDATE('2003-01-06',
INTERVAL 7*(WEEK('2003-11-12')-1) DAY),ADDDATE('2003-01-06', INTERVAL
7*(WEEK('2003-11-12')-1)+6 DAY);

but there is constant  '2003-01-06', that's date of first Monday (Monday
because i'm Czech) of first week in a year.
There is a lot of ways to number weeks, see WEEK() function .

I think it's impossible to get this date (the date of first day of first
week) just in query, maybe you can write your own function ;))
But if you are using something like PHP etc., you can simply go throw 6 days
before and after your date, and simply check while the week number is same
like weeknumber you got from mysql.
I hope that it helps you little.


`WEEK(date [,mode])'
     The function returns the week number for `date'.  The two-argument
     form of `WEEK()' allows you to specify whether the week starts on
     Sunday or Monday and whether the return value should be in the
     range 0-53 or 1-52. When `mode' argument is omitted the value of a
     `default_week_format' server variable (or 0 in MySQL 4.0 or
     earlier) is assumed. *Note SET OPTION::.

     The following table demonstrates how the `mode' argument works:

     *Value* *Meaning*
     0       Week starts on Sunday; return value range is 0 to 53;
             week 1 is the first week that starts in this year
     1       Week starts on Monday; return value range is 0 to 53;
             week 1 is the first week that has more than 3 days in
             this year
     2       Week starts on Sunday; return value range is 1 to 53;
             week 1 is the first week that starts in this year
     3       Week starts on Monday; return value range is 1 to 53;
             week 1 is the first week that has more than 3 days in
             this year
     4       Week starts on Sunday; return value range is 0 to 53;
             week 1 is the first week that has more than 3 days in
             this year
     5       Week starts on Monday; return value range is 0 to 53;
             week 1 is the first week that starts in this year
     6       Week starts on Sunday; return value range is 1 to 53;
             week 1 is the first week that has more than 3 days in
             this year
     7       Week starts on Monday; return value range is 1 to 53;
             week 1 is the first week that starts in this year

     The `mode' value of 3 can be used as of MySQL 4.0.5.  The `mode'
     value of 4 and above can be used as of MySQL 4.0.17.


----- Original Message -----
From: "Trevor Smith" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, January 26, 2004 12:56 PM
Subject: yearweek() result back to date format?


> How can I use the output string of the yearweek() function
> (for example, "200346" below):
>
>   mysql> select dayname("2003-11-12"), yearweek("2003-11-12");
>   +-----------------------+------------------------+
>   | dayname("2003-11-12") | yearweek("2003-11-12") |
>   +-----------------------+------------------------+
>   | Wednesday             |                 200346 |
>   +-----------------------+------------------------+
>   1 row in set (0.00 sec)
>
> to extract the start and end dates for that week (for example,
"2003-11-09"
> and "2003-11-15" above)?
>
> I'm using server v3.23.
>
> --
>  Trevor Smith    |    [EMAIL PROTECTED]
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
>
>


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to