Hi,
I am trying to create a query that returns a users availability for the next ten days using version 4.1.11. A user has 8.5 hours available per day so a users availability is equal to 8.5 less any bookings they have on that day. I have a table called Bookings (see below), and each 'Booking' has a start date and time and an end date and time. Dates for bookings don't have to be the same, i.e. a user could be on holiday for a week.
The follwing query produces an empty result:
SELECT (8.5 - TIMEDIFF(B.Booking_End_Date, B.Booking_Start_Date)) AS 'Availability' FROM Bookings B WHERE B.User_ID = '1' AND NOT ( CURDATE() < DATE_FORMAT(Booking_Start_Date, "%Y-%m-%d") CURDATE() > DATE_FORMAT(Booking_End_Date, "%Y-%m-%d") ) GROUP BY Availability ORDER BY B.Booking_Start_Date;
Here is the Definition for the bookings table:
+---------------------------------------------+-------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------------------------------------+-------------+------+-----+---------------------+----------------+
| Booking_ID | int(11) | | PRI | NULL | auto_increment |
| Booking_Type | varchar(15) | | | Unavailability | |
| User_ID | int(11) | | | 0 | |
| Project_ID | int(11) | YES | | NULL | |
| Booking_Creator_ID | int(11) | YES | | NULL | |
| Booking_Creation_Date | datetime | YES | | NULL | |
| Booking_Start_Date | datetime | | | 0000-00-00 00:00:00 | |
| Booking_End_Date | datetime | | | 0000-00-00 00:00:00 | |
| Booking_Status | varchar(15) | | | Other | |
| Additional_Notes | text | YES | | NULL | |
+---------------------------------------------+-------------+------+-----+---------------------+----------------+
Thanks for any advice offered here
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]