Hi,
You can use the WEEK function
http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html

and the query will look like 

select week(Date) as weekID,User_ID,sum(hours) from Timesheets group by 
weekID,User_ID order by weekID;

You will have to do some additional math in your application to retrieve the 
dates when a week starts/ends but this should nto be a problem

HTH
-- 
Dobromir Velev
[EMAIL PROTECTED]
http://www.websitepulse.com/


On Tuesday 26 October 2004 16:28, shaun thornburgh wrote:
> Hi,
>
> I am creating an online timesheet application. Most parts are done, however
> I have a problem displaying a list of unapproved timesheets.
>
> Here is my timesheet table:
>
> mysql> DESCRIBE Timesheets;
> +-------------------+-------------+------+-----+------------+--------------
>--+
>
> | Field             | Type        | Null | Key | Default    | Extra
>
> +-------------------+-------------+------+-----+------------+--------------
>--+
>
> | Timesheet_ID      | int(11)     |      | PRI | NULL       |
> | auto_increment
> |
> | Type              | varchar(40) | YES  |     | NULL       |
> |
> | Project_ID        | int(11)     | YES  |     | NULL       |
> |
> | User_ID           | int(11)     |      |     | 0          |
> |
> | Hours             | float       |      |     | 0          |
> |
> | Date              | date        |      |     | 0000-00-00 |
> |
> | Status            | varchar(40) | YES  |     | Open       |
>
> +-------------------+-------------+------+-----+------------+--------------
>--+
>
> When a timesheet is submitted for approval the manager logs in and approves
> / rejects the timesheets. How can I display a list of unapproved timesheets
> grouped by week and user? i.e.
>
> Week 1 - Bill - 45 Hours
> Week 1 - Fred - 40 Hours
> Week 2 - Bill - 45 Hours
> Week 2 - Fred - 40 Hours
> Week 2 - Sam  - 12 Hours
>
> Thanks for your help.



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

Reply via email to