如果时间超过下午14:30或2:30,则在datediff结果中加1



这是我的SQL查询,它通过从指定日期中减去当前日期来返回天数,并根据我的需要返回确切的天数,但此外,如果当前时间超过14:30或2:30,我希望在结果中加1。

我的查询

SELECT reservations.customerid,
       DateDiff("d",reservations.checkin_date,Now()) AS Due_nights
FROM reservations

我正在使用MS Access DB

可能是:

SELECT 
    reservations.customerid,
    DateDiff("d",reservations.checkin_date, Date()) 
        + Abs(DateDiff("s", #14:30#, Time()) > 0)AS Due_nights
FROM 
    reservations

相关内容

最新更新