我正在创建一个显示客户报价的报告,我需要有关如何计算两个日期之间的周转时间的帮助。
我没有尝试过任何事情,因为我不知道从哪里开始。
我正在尝试从到达日期和完成日期获得周转时间
select dbo.paf.Nombre as 'CustomerName', dbo.Comerciales.Nombre, dbo.CMSStaff.Login,
dbo.paf.ShipToContactName, dbo.paf.obra, dbo.AW_QuoteLog.Difficulty, dbo.paf.SubTotal,
dbo.AW_QuoteLOg.Quote_Returned, dbo.AW_QuoteLog.Bid_Required, dbo.AW_QuoteLog.Timestamp
from dbo.paf
left join dbo.Comerciales on dbo.paf.Salesmancode = dbo.Comerciales.Codigo
left join dbo.CMSStaff on dbo.paf.UserCode = dbo.CMSStaff.accountid
left join dbo.AW_QuoteLog on dbo.paf.numero = AW_QuoteLog.Order_number and dbo.paf.version = AW_QuoteLog.Version_number
where dbo.AW_QuoteLog.Timestamp > '2019-01-01' and dbo.Aw_QuoteLog.Quote_Returned is null
order by dbo.AW_QuoteLog.Timestamp ASC;
答案 0 :(得分:1)
要计算两个日期之间的时差,可以使用DATEDIFF
函数。只需在查询中添加一个新的计算字段即可:
DATEDIFF(day, [Date Arrived], [Date Completed]) AS Turnaround