时间差值
alter procedure Asset_spQueryAlertInfomation
(
@pi_Action VARCHAR(100),
@pi_InfoId BIGINT,
@pi_pageIndex INT,
@pi_pageSize INT,
@po_recordCount BIGINT OUTPUT
)
as
DECLARE @pt_StartRowIndex INT
DECLARE @pt_EndRowIndex INT
SET @pt_StartRowIndex = (@pi_pageIndex - 1) * @pi_pageSize + 1
SET @pt_EndRowIndex = @pi_pageIndex * @pi_PageSize
IF @pi_Action = 'getlist'
BEGIN
SELECT * FROM
(
SELECT Asset_ReceiptDetail.InfoId, Asset_Subject.SubjectCode, Asset_Subject.SubjectName, Asset_Contract_ChargePlan.CostStartDate, Asset_Contract_ChargePlan.CostEndDate,
Asset_Contract_ChargePlan.ShouldGetDate, Asset_Contract_ChargePlan.SumMoney, Asset_ReceiptMain.ContractCode,
Asset_Contract_ChargePlan.ChargePlanCode, Asset_ReceiptDetail.IsReceipt,
ROW_NUMBER() OVER (ORDER BY Asset_Contract_ChargePlan.InfoId DESC) AS RowIndex,
'IsReceipts' = (
CASE
WHEN IsReceipt = 0 THEN '否'
when IsReceipt is null then '否'
ELSE
'是'
End)
FROM Asset_ChargedItems INNER JOIN
Asset_Contract_ChargePlan ON Asset_ChargedItems.ChargedItemCode = Asset_Contract_ChargePlan.ChargedItemCode INNER JOIN
Asset_Subject ON Asset_ChargedItems.SubjectCode = Asset_Subject.SubjectCode INNER JOIN
Asset_ReceiptMain ON Asset_Contract_ChargePlan.ContractCode = Asset_ReceiptMain.ContractCode LEFT JOIN
Asset_ReceiptDetail ON Asset_Contract_ChargePlan.ChargePlanCode = Asset_ReceiptDetail.ChagePlanCode
WHERE datediff(day,getdate(),Asset_Contract_ChargePlan.ShouldGetDate)<=30 and datediff(day,getdate(),Asset_Contract_ChargePlan.ShouldGetDate)>=0
--应收日期与当前日期差值小于30天的记录同时是正值
)tba
WHERE RowIndex BETWEEN @pt_StartRowIndex AND @pt_EndRowIndex
SELECT @po_recordCount = COUNT(*)
FROM Asset_ChargedItems INNER JOIN
Asset_Contract_ChargePlan ON Asset_ChargedItems.ChargedItemCode = Asset_Contract_ChargePlan.ChargedItemCode INNER JOIN
Asset_Subject ON Asset_ChargedItems.SubjectCode = Asset_Subject.SubjectCode INNER JOIN
Asset_ReceiptMain ON Asset_Contract_ChargePlan.ContractCode = Asset_ReceiptMain.ContractCode LEFT JOIN
Asset_ReceiptDetail ON Asset_Contract_ChargePlan.ChargePlanCode = Asset_ReceiptDetail.ChagePlanCode
WHERE datediff(day,getdate(),Asset_Contract_ChargePlan.ShouldGetDate)<=30 and datediff(day,getdate(),Asset_Contract_ChargePlan.ShouldGetDate)>=0
end