Hotel Booking Rates SQL Problem

后端 未结 3 560
清歌不尽
清歌不尽 2021-01-16 07:33

Hi I\'ve been trying to get my own system for checking rooms rates going after reading other questions here on StackOverflow.

My query works fine and produces corre

3条回答
  •  广开言路
    2021-01-16 07:39

    Between 2011-04-16 16:00 and 2011-04-15 00:00 there is one day and 16 hours, therefore your DATEDIFF(...)+1 is returning (correctly) 1+1 days.

    The issue here is the mismatch between the time when the guest arrives/leaves (around noon) and the time when the rate changes (at midnight).

    You have to check your requirements, but probably you could ignore the last partial day and have the guest "leave" at 2011-04-15 23:59:59 for rate calculation purposes. In the same way, have the guest "arrive" at 2011-04-14 00:00:00. The extra hours in the first day will compensate the missing hours in the last day.

提交回复
热议问题