→ 🚀What's New? Join Us for the Fall Product Launch! Register Now !
‎06-02-2020 05:31 PM
Solved! Go to Solution.
‎06-02-2020 10:17 PM
CASE
WHEN tblAssetCustom.PurchaseDate IS NULL THEN '#ff00ff' -- no purchase date: magic pink
WHEN DateAdd(dd, 5*365.2425, tblAssetCustom.PurchaseDate) < GetDate() THEN '#ff0000' -- more than 5yo: red
END AS foregroundcolor
‎06-12-2020 10:20 PM
‎06-12-2020 09:14 PM
‎06-02-2020 10:28 PM
‎06-11-2020 07:29 PM
Josh R Smith wrote:
Oh, man. That's wonderful. Thank you so much!
‎06-11-2020 10:15 PM
rader wrote:Josh R Smith wrote:
Oh, man. That's wonderful. Thank you so much!
Would you mind posting the complete code here. I'm trying to get the color to work so I can use the structure in another report, and I'm having a heck of a time getting it to work. I've tried adding the snippet code from RC62N to your report, but all I get is Invalid "Select" statement. Unexpected token "Case" at line xx, pos x.
Thanks.
Select Top 10000000 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,
Case
When tblAssetCustom.PurchaseDate Is Null Then '#ff00ff'
When DateAdd(dd, 5 * 365.2425, tblAssetCustom.PurchaseDate) < GetDate() Then
'#ff0000'
End As foregroundcolor
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 'HCA School'
Order By tsysAssetTypes.AssetTypename,
tblAssets.AssetName
‎06-02-2020 10:17 PM
CASE
WHEN tblAssetCustom.PurchaseDate IS NULL THEN '#ff00ff' -- no purchase date: magic pink
WHEN DateAdd(dd, 5*365.2425, tblAssetCustom.PurchaseDate) < GetDate() THEN '#ff0000' -- more than 5yo: red
END AS foregroundcolor
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now