DATEPART 函数数据集保存,数据库正常运行select
DISTINCT
A.OrderBy_Code as 客户编码
,A1.OrderBy_Name as 客户名字
,A2.ItemInfo_ItemName as 料品名字
,A2.ItemInfo_ItemCode as 料号
--,A2.ShipQtyInvAmount as 数量
--,A.CreatedOn AS 历史出货时间
--,A.CreatedBy AS 历史出货制单人
--,A.DocNo AS 对应销售订单号
,A.BusinessDate as 业务时间
,DATEPART(year, BusinessDate) as 业务年份
,DATEPART(month, BusinessDate) as 业务月份
,DATEPART(year, getdate()) as 当前年份
,DATEPART(month,getdate()) as 当前月份
from SM_Ship as A
inner join [SM_Ship_Trl] as A1 on (A1.SysMlFlag = 'zh-CN') and (A.[ID] = A1.[ID])
inner join [SM_ShipLine] as A2 on (A.[ID] = A2.[Ship])
where 1=1
and DATEPART(year, BusinessDate)=DATEPART(year, getdate())
and DATEPART(month, BusinessDate)=DATEPART(month,getdate()) |