Does anyone know of a way to get the start and end dates of each week of the 
year (preferably starting on Mondays) using v3.23? Here's why:

I am trying to extract the sum of a column for each week. No problem, I use 
"group by yearweek()" to get it.

So my query looks like this:

select sum(hours_worked) from tips group by yearweek(delivery_date) order by 
delivery_date;

However, I also want to print the start and end dates of each week listed.

I have access to the string produced by yearweek() (such as '200305') but 
don't know how to convert that to the first and/or last date in that 
yearweek(). If I was using v4.1.1, it appears I may be able to use 
STR_TO_DATE() with some format options to convert the result of yearweek() 
back into a date, then tack 7 days on it and bam, I'm done. However, I'm 
using v3.23 and upgrading to v4.1.1 is a daunting task for me. Especially for 
this trivial purpose.

BTW, you might ask, "why not just print the date from the first entry for that 
week from your table (simple) and also print it + 7 days (also simple) as the 
start and end dates?" The answer is that there are not entries for every day 
in every week in my table. Therefore there might be no data entered until 
Wednesday of any given week. So the first date with data entered for a given 
week is variable and adding 7 days to it would not produce a predictable or 
desirable result.

-- 
 Trevor Smith    |    [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