1 -between and 包括边界值,如果是日期 截止日期到00点0分 如果截止日期:2019-7-26 则为:2019-7-26 00:00:00
not between and 不包括边界值
2 复制表
select * into newtable from oldtable where 1=2
insert into newtable select * from oldtable
3 取库龄
Select PartInnerCode,StorageInnerCode,RemainAmount as InAmount,RM ,InOutDate,p.PartName,s.StorageName,
DateDiff(Day,InOutDate,GetDate())
From tbStorageDetail d inner join tbInfoPart p on d.PartInnerCode=p.InnerCode
inner join tbInfoStorage s on d.StorageInnerCode=s.InnerCode
Where (RemainAmount>0) and DateDiff(Day,InOutDate,GetDate())>=4-- Between 2 And 3
and PartName ='测试商品1'