I'm trying to create a Warranty Report where I input the date range I want to serach on and I get back all the machines with warranties ending in that date range.
I'm getting this error message I just can't get around:
Code:
Sql error in query. Error: System.Data.SqlClient.SqlError: Conversion failed when converting datetime from character string.Sql CommandText: -- MAX ROWCOUNT SET ROWCOUNT 50000 -- SELECT T0.[Name] AS 'Computer Name', T2.[Computer Model] AS 'Computer Model', T1.[Warranty end date] AS 'Warranty end date' FROM [Inv_AeX_AC_Identification] T0 INNER JOIN [Inv_AeX_HW_Serial_Number] T2 ON T0.[_ResourceGuid] = T2.[_ResourceGuid] INNER JOIN [Inv_Warranty_End_Date] T1 ON T0.[_ResourceGuid] = T1.[_ResourceGuid] WHERE T1.[Warranty end date] >= 'BeginDate' AND T1.[Warranty end date] <= 'EndDate' ORDER BY T2.[Computer Model] ASC, T1.[Warranty end date] ASC
Here is the query:
Code:
SELECT T0.[Name] AS 'Computer Name', T2.[Computer Model] AS 'Computer Model', T1.[Warranty end date] AS 'Warranty end date' FROM [Inv_AeX_AC_Identification] T0 INNER JOIN [Inv_AeX_HW_Serial_Number] T2 ON T0.[_ResourceGuid] = T2.[_ResourceGuid] INNER JOIN [Inv_Warranty_End_Date] T1 ON T0.[_ResourceGuid] = T1.[_ResourceGuid] WHERE T1.[Warranty end date] >= 'BeginDate' AND T1.[Warranty end date] <= 'EndDate' ORDER BY T2.[Computer Model] ASC, T1.[Warranty end date] ASC
I have defined Global Parameters BeginDate and EndDate as date/time. I have tried the various formats as well, from Short to Long to Custom.
When I remove the WHERE part of the query, the query does return results, but of course that negates the parameters.
When the results do come back for the Warranty End Date, it comes out as mm/dd/yyyy hh:mm:ss AM
I'm guessing this has something to do with it, but since I'm a bit of a dummy on SQL, I'm not sure.
Any assistance would be greatly appreciated.