‎01-28-2021 05:57 PM
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
tsysOS.OSname,
tblAssets.Username As LastUserLogin,
tblAssets.IPAddress,
tblAssets.Description,
DateDiff(day, Max(Convert(datetime,tblAssets.Lastseen)), GetDate()) As
DaysSinceSeen,
DateDiff(day, Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)),
GetDate()) As DaysSincePatched,
Convert(Decimal(12,0),tblAssets.Uptime / 86400) As UptimeDays,
Case
When
DateDiff(day, Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 0 And 7 Then '#6efa72'
When
DateDiff(day, Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 7 And 12 Then '#77ea6b'
When
DateDiff(day, Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 12 And 16 Then '#80d965'
When
DateDiff(day, Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 16 And 20 Then '#89c95e'
When
DateDiff(day, Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 20 And 24 Then '#93b958'
When
DateDiff(day, Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 24 And 28 Then '#9ca951'
When
DateDiff(day, Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 28 And 32 Then '#a5984b'
When
DateDiff(day, Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 32 And 36 Then '#ae8844'
When
DateDiff(day, Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 36 And 40 Then '#b7783d'
When
DateDiff(day, Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 40 And 44 Then '#c06737'
When
DateDiff(day, Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 44 And 48 Then '#c95730'
When
DateDiff(day, Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 48 And 52 Then '#d3472a'
When
DateDiff(day, Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 52 And 56 Then '#dc3723'
When
DateDiff(day, Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 56 And 60 Then '#e5261d'
Else '#f7caca'
End As backgroundcolor
From tblQuickFixEngineering
Join tblAssets On tblAssets.AssetID = tblQuickFixEngineering.AssetID
Join tsysOS On tblAssets.OScode = tsysOS.OScode
Where tblAssets.Lastseen > GetDate() - 2
Group By tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
tsysOS.OSname,
tblAssets.Username,
tblAssets.IPAddress,
tblAssets.Description,
tblAssets.Lastseen,
tblAssets.Uptime
Order By DaysSincePatched
‎07-15-2021 05:14 PM
‎03-30-2021 08:56 PM
The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.
‎07-27-2021 03:24 PM
ldockery wrote:
Generates this error:The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.
‎10-06-2021 01:54 PM
Madrilleno wrote:ldockery wrote:
Generates this error:The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.
Same error for me.
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
tsysOS.OSname,
tblAssets.Username As LastUserLogin,
tblAssets.IPAddress,
tblAssets.Description,
DateDiff(day, Max(Convert(datetime2,tblAssets.Lastseen)), GetDate()) As
DaysSinceSeen,
DateDiff(day, Max(Convert(datetime2,tblQuickFixEngineering.InstalledOn)),
GetDate()) As DaysSincePatched,
Convert(Decimal(12,0),tblAssets.Uptime / 86400) As UptimeDays,
Case
When
DateDiff(day, Max(Convert(datetime2,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 0 And 7 Then '#6efa72'
When
DateDiff(day, Max(Convert(datetime2,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 7 And 12 Then '#77ea6b'
When
DateDiff(day, Max(Convert(datetime2,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 12 And 16 Then '#80d965'
When
DateDiff(day, Max(Convert(datetime2,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 16 And 20 Then '#89c95e'
When
DateDiff(day, Max(Convert(datetime2,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 20 And 24 Then '#93b958'
When
DateDiff(day, Max(Convert(datetime2,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 24 And 28 Then '#9ca951'
When
DateDiff(day, Max(Convert(datetime2,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 28 And 32 Then '#a5984b'
When
DateDiff(day, Max(Convert(datetime2,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 32 And 36 Then '#ae8844'
When
DateDiff(day, Max(Convert(datetime2,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 36 And 40 Then '#b7783d'
When
DateDiff(day, Max(Convert(datetime2,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 40 And 44 Then '#c06737'
When
DateDiff(day, Max(Convert(datetime2,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 44 And 48 Then '#c95730'
When
DateDiff(day, Max(Convert(datetime2,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 48 And 52 Then '#d3472a'
When
DateDiff(day, Max(Convert(datetime2,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 52 And 56 Then '#dc3723'
When
DateDiff(day, Max(Convert(datetime2,tblQuickFixEngineering.InstalledOn)),
GetDate()) Between 56 And 60 Then '#e5261d'
Else '#f7caca'
End As backgroundcolor
From tblQuickFixEngineering
Join tblAssets On tblAssets.AssetID = tblQuickFixEngineering.AssetID
Join tsysOS On tblAssets.OScode = tsysOS.OScode
Where tblAssets.Lastseen > GetDate() - 2
Group By tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
tsysOS.OSname,
tblAssets.Username,
tblAssets.IPAddress,
tblAssets.Description,
tblAssets.Lastseen,
tblAssets.Uptime
Order By DaysSincePatched
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now