我有一张包含当前日期和交货日期的表格。我想从当前日期减去截止日期,并且只想在dbtable
中保留剩余天数SELECT clientId,
curentDate,
deliveryDate DATEDIFF(day,-(deliveryDate) CURRENT_TIMESTAMP) AS Days_Left
FROM dbo.tblorder
e.g:
12/1/2014
20/1/2014
答案 0 :(得分:1)
您是否在the documentation查看有关如何使用DATEDIFF
的示例?
SELECT clientId, currentDate, deliveryDate,
Days_Left = DATEDIFF(DAY, CURRENT_TIMESTAMP, deliveryDate)
FROM dbo.tblorder;