Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. The easiest way to accomplish this would be to do this sort of thing, and simply return any slot that doesn't have one following, but amend onto it the length of the booking. This code will return all available slots that follow an existing slot:
  2.  
  3. SELECT
  4. P.BookDate, P.BookSlot + 30
  5. FROM Bookings P
  6. LEFT JOIN Bookings U
  7. ON U.BookDate = P.BookDate
  8. AND U.BookSlot = P.BookSlot + 30
  9. WHERE U.BookDate IS NULL
  10.  
  11. After this you would want to account for when now is, check if there's a slot now, and return the smallest slot that is still greater than the current date/time. Unfortunately I've no ability to test T-SQL code, so I'm not going to be able to write this, hopefully this will help though(also, if you actually used a datetime to store the time of the appointment this would be easy).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement