cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
kiran
Engaged Sweeper
hi all, below is my statement. the below generates all assets and does not provide me with the 90 days. can anyone help advise please.


Select Top 1000000 tsysAssetTypes.AssetTypeIcon10 As icon,
tblAssets.AssetID,
tblAssets.AssetName,
tblAssetCustom.Serialnumber,
tblAssetCustom.PurchaseDate As [Purchase Date],
tblAssetCustom.Warrantydate As [Warranty Expiration],
tblAssets.Username,
tblAssets.Userdomain,
tsysAssetTypes.AssetTypename As Type,
tblAssets.IPAddress,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tsysIPLocations.IPLocation,
tblAssets.Firstseen,
tblAssets.Lastseen,
tblADusers.Department,
TsysChassisTypes.ChassisName
From tblAssetCustom
Inner Join tblAssets On tblAssetCustom.AssetID = tblAssets.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Inner Join tblADusers On tblAssets.Username = tblADusers.Username
Inner Join tblSystemEnclosure On tblAssets.AssetID = tblSystemEnclosure.AssetID
Inner Join TsysChassisTypes On tblSystemEnclosure.ChassisTypes = TsysChassisTypes.Chassistype
Left Join tsysIPLocations On tblAssets.LocationID = tsysIPLocations.LocationID
Where (tblAssetCustom.Warrantydate < GetDate() + 90 And tblAssetCustom.State = 1) And
(TsysChassisTypes.ChassisName = 'Laptop') Or
(TsysChassisTypes.ChassisName = 'Notebook') Or
(TsysChassisTypes.ChassisName = 'Portable') Or
(TsysChassisTypes.ChassisName = 'Desktop')
Order By [Warranty Expiration] Desc
1 REPLY 1
RCorbeil
Honored Sweeper II
DateDiff() is your friend.

Try this:
WHERE
DateDiff(dd, GetDate(), tblAssetCustom.Warrantydate) <= 90
-- optionally, if you don't want those where the warranty is already expired:
AND DateDiff(dd, GetDate(), tblAssetCustom.Warrantydate) >= 0
AND ...