dbTalk Databases Forums  

HELP with a DATETIME Query

comp.databases.theory comp.databases.theory


Discuss HELP with a DATETIME Query in the comp.databases.theory forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Shaun
 
Posts: n/a

Default HELP with a DATETIME Query - 10-05-2003 , 03:48 PM






Hi,

I have a table called Bookings which has two important columns;
Booking_Start_Date and Booking_End_Date. These columns are both of type
DATETIME. The following query calculates how many hours are available
between the hours of 09.00 and 17.30 so a user can see at a glance how many
hours they have unbooked on a particular day (i.e. 8.5 hours less the time
of any bookings on that day). However, when a booking spans more than one
day the query doesn't work, for example if a user has a booking that starts
on day one at 09.00 and ends at 14.30 on the next day, the query returns 3.5
hours for both days. Any help here would be greatly appreciated.

SELECT 8.5 - (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 WMS_Bookings B WHERE B.User_ID = '16' AND
B.Booking_Status <> '1' AND NOT ( '2003-10-07' <
DATE_FORMAT(Booking_Start_Date, "%Y-%m-%d") OR '2003-10-07' >
DATE_FORMAT(Booking_End_Date, "%Y-%m-%d") )

Thanks for your help



Reply With Quote
  #2  
Old   
Shaun
 
Posts: n/a

Default Re: HELP with a DATETIME Query - 10-07-2003 , 03:38 PM






mysql 3.23

"Seun Osewa" <seunosewa (AT) inaira (DOT) com> wrote

Quote:
what database?



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.