Hello,
I am creating two reports that show the last time an update was installed. Both are failing and i could really use help.
First issue:The date value i am returning from the reg scan of the last installs date from "SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Install" is 2015-10-19 21:57:40. Which looks like a date but i cant apply any date filters such as > GetDate() - 60 or MAX or any type of meaningfully sorting.
The two errors i get are:
error while getting report
The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value
error while getting report
Conversion failed when converting date and/or time from character string.
I tried using substring to make the field look like 10/19/2015 but sorting with > Getdate's still fail.
Sample of one of my report attempts is below, also i have tried "convert(datetime, Tablename, 101)" and "Cast(tablename as datetime)" and then i just get a cant covert to datetime error.
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
Convert(datetime,(SubString(tblRegistry.Value, 1,
10))) As [Last Install Date],
Convert(datetime,(SubString(tblRegistry1.Value, 1,
10))) As [Last Download Date]
From tblAssets
Inner Join tblRegistry On tblAssets.AssetID = tblRegistry.AssetID
Inner Join tblRegistry tblRegistry1 On tblAssets.AssetID =
tblRegistry1.AssetID
Where Convert(datetime,(SubString(tblRegistry.Value, 1, 10))) > GetDate() - 60
And tblRegistry.Valuename Like '%LastS%' And tblRegistry.Regkey Like
'%Install' And tblRegistry1.Regkey Like '%Download%' And tblAssets.Assettype =
-1
Second Issue:Similar to the first one i have the below report when i run it without grouping every computer shows every hotfix thats installed. I just want to show the latest installed hotfix. While i can group the computer into one entry, i have no way of grabbing the latest date installed since the field with the date is not a date field!
Select Top 1000000 tblAssets.AssetID As AssetID1,
tblAssets.AssetName,
tblQuickFixEngineeringUni.HotFixID,
tblQuickFixEngineeringUni.Description,
Max(tblQuickFixEngineering.InstalledOn)
From tblAssets
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 tblQuickFixEngineering On tblAssets.AssetID =
tblQuickFixEngineering.AssetID
Inner Join tblQuickFixEngineeringUni On tblQuickFixEngineeringUni.QFEID =
tblQuickFixEngineering.QFEID,
tsysOS
Where tblAssetCustom.State = 1
Group By tblAssets.AssetID,
tblAssets.AssetName
Order By tblAssets.AssetName,
Max(tblQuickFixEngineering.InstalledOn) Desc
Thanks!!!