‎08-18-2017 02:19 AM
Convert(Decimal(7,2),tblAssets.Uptime / 60 / 60 / 24) As [Days up]
tblAssets.Lastseen - Convert(Decimal,tblAssets.Uptime / 60 / 60 / 24) As [Boot Time]
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypeIcon10 As icon,
Convert(Decimal(7,2),tblAssets.Uptime / 60 / 60 / 24) As [Days up],
tblAssets.Lastseen - Convert(Decimal,tblAssets.Uptime / 60 / 60 / 24) As [Boot Time],
tblAssetCustom.Location,
tblAssets.Lastseen,
Left(tblADComputers.OU, CharIndex(',', tblADComputers.OU) - 1) As OU,
'<img src="thumbnail.aspx?user=' + tblADusers.Username + '&domain=' +
tblADusers.Userdomain + '&size=12" class="rimage"/>' As Picture,
tblADusers.Displayname,
tblADusers.Username,
tblADusers.Userdomain,
tblAssetCustom.Model,
tblOperatingsystem.Version As [OS Version],
tblOperatingsystem.Caption As [OS Name],
tsysIPLocations.IPLocation,
tblAssets.Description As [LS Description],
tblADComputers.Description As [AD Description]
From tblAssets
Left Outer Join tblComputersystem On tblAssets.AssetID =
tblComputersystem.AssetID
Left Outer Join tblADusers On tblAssets.Username = tblADusers.Username
Left Outer Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Left Outer Join tsysAssetTypes On tsysAssetTypes.AssetType =
tblAssets.Assettype
Left Outer Join tblADComputers On tblAssets.AssetID = tblADComputers.AssetID
Left Outer Join tblOperatingsystem On tblAssets.AssetID =
tblOperatingsystem.AssetID
Left Outer Join tsysIPLocations On tsysIPLocations.LocationID =
tblAssets.LocationID
Where tblComputersystem.Domainrole < 2 And tblAssetCustom.State = 1 And
tblAssets.Lastseen - Convert(Decimal,tblAssets.Uptime / 60 / 60 / 24) < Getdate() - 14
Order By tblAssets.Lastseen - Convert(Decimal,tblAssets.Uptime / 60 / 60 / 24) Asc, tblAssets.Uptime Desc,
tblAssets.AssetName
‎09-10-2019 09:21 AM
‎05-17-2019 08:44 AM
‎01-15-2019 10:54 PM
jperry wrote:
The uptime is great if your workstations are reliably checking in.Convert(Decimal(7,2),tblAssets.Uptime / 60 / 60 / 24) As [Days up]
The issue is when you want to know WHEN was the last reported reboot.
Laptops may not have reported in for a couple weeks, yet still show an uptime of less than one day.
You can calculate the last boot time with the tblAssets.Uptime and blAssets.LastseentblAssets.Lastseen - Convert(Decimal,tblAssets.Uptime / 60 / 60 / 24) As [Boot Time]
I tend to be fairly verbose in my reports.Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypeIcon10 As icon,
Convert(Decimal(7,2),tblAssets.Uptime / 60 / 60 / 24) As [Days up],
tblAssets.Lastseen - Convert(Decimal,tblAssets.Uptime / 60 / 60 / 24) As [Boot Time],
tblAssetCustom.Location,
tblAssets.Lastseen,
Left(tblADComputers.OU, CharIndex(',', tblADComputers.OU) - 1) As OU,
'<img src="thumbnail.aspx?user=' + tblADusers.Username + '&domain=' +
tblADusers.Userdomain + '&size=12" class="rimage"/>' As Picture,
tblADusers.Displayname,
tblADusers.Username,
tblADusers.Userdomain,
tblAssetCustom.Model,
tblOperatingsystem.Version As [OS Version],
tblOperatingsystem.Caption As [OS Name],
tsysIPLocations.IPLocation,
tblAssets.Description As [LS Description],
tblADComputers.Description As [AD Description]
From tblAssets
Left Outer Join tblComputersystem On tblAssets.AssetID =
tblComputersystem.AssetID
Left Outer Join tblADusers On tblAssets.Username = tblADusers.Username
Left Outer Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Left Outer Join tsysAssetTypes On tsysAssetTypes.AssetType =
tblAssets.Assettype
Left Outer Join tblADComputers On tblAssets.AssetID = tblADComputers.AssetID
Left Outer Join tblOperatingsystem On tblAssets.AssetID =
tblOperatingsystem.AssetID
Left Outer Join tsysIPLocations On tsysIPLocations.LocationID =
tblAssets.LocationID
Where tblComputersystem.Domainrole < 2 And tblAssetCustom.State = 1 And
tblAssets.Lastseen - Convert(Decimal,tblAssets.Uptime / 60 / 60 / 24) < Getdate() - 14
Order By tblAssets.Lastseen - Convert(Decimal,tblAssets.Uptime / 60 / 60 / 24) Asc, tblAssets.Uptime Desc,
tblAssets.AssetName
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now