I have a report that I'm using to list devices in a certain Asset Group. I'm wanting to highlight devices that are older than 5 years to help managers visually see what needs budgeted to be replaced.
In the report below, I'm using a string I found to take the Purchase Date, add 5 years, and then display that as a number.
Cast(DateDiff(dd, tblAssetCustom.PurchaseDate, GetDate()) / 365.2425 As numeric(8,1)) As Age
I would love for that number to be displayed in red, if the date is older than today.
I've also seen this line used:
Case When tblAssetCustom.Warrantydate < GetDate() Then 'red' End As foregroundcolor,
If I could take the tablAssetCustom.PurchaseDate + 5 years, IF older than today, make it red. That also works. Thanks in advance!
Select Top 1000000 tblAssets.AssetName,
tblADComputers.Description,
tsysAssetTypes.AssetTypename,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tblAssets.Username As [Last Login],
tblAssetCustom.PurchaseDate,
tblAssetCustom.Warrantydate,
Cast(DateDiff(dd, tblAssetCustom.PurchaseDate, GetDate()) / 365.2425 As numeric(8,1)) As Age
From tblAssets
Inner Join tblADComputers On tblADComputers.AssetID = tblAssets.AssetID
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tblAssetGroupLink On tblAssets.AssetID = tblAssetGroupLink.AssetID
Inner Join tblAssetGroups On tblAssetGroups.AssetGroupID =
tblAssetGroupLink.AssetGroupID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Where tblAssetCustom.State = 1 And tblAssetGroups.AssetGroup Like 'DEPARTMENT'
Order By tsysAssetTypes.AssetTypename,
tblAssets.AssetName