Hi,
I have a table called Bookings which holds information for bookings(!) for staff members in my database:
mysql> DESCRIBE Bookings;
+-----------------------+-------------+------+-----+----------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------+-------------+------+-----+----------------+----------------+
| Booking_ID | int(11) | | PRI | NULL | auto_increment |
| User_ID | int(11) | | | 0 | |
| Booking_Start_Date | datetime | YES | | NULL | |
| Booking_End_Date | datetime | YES | | NULL | |
+-----------------------+-------------+------+-----+----------------+----------------+
I use the following query to extract how many hours have been worked ona a particular day:
SELECT (SUM(((DATE_FORMAT(B.Booking_End_Date, "%k") * 60 ) +
DATE_FORMAT(B.Booking_End_Date, "%i")) -
((DATE_FORMAT(B.Booking_Start_Date, "%k") * 60 ) +
DATE_FORMAT(B.Booking_Start_Date, "%i"))) / 60 ) AS Available_Hours
FROM Bookings B
WHERE B.User_ID = "1"
AND NOT ( "2004-10-25" < DATE_FORMAT(Booking_Start_Date, "%Y-%m-%d")
OR "2004-10-25" > DATE_FORMAT(Booking_End_Date, "%Y-%m-%d") )
Is it possible to group this information by day for the next seven days?
Thanks for your help
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]