I have the current statement:
SELECT DISTINCT CAST([WhenOccurred] AS DATE) AS ‘DateOf’
FROM [DBName].[MyApp].[ErrorLog]
WHERE [WhenOccurred] > '2/1/2023' AND UPPER([ErrorMessage]) LIKE '%TIMEOUT%'
Which returns the Dates that meet the criteria.
I would like to Count the Observations for each date.
I have tried:
SELECT DISTINCT CAST([WhenOccurred] AS DATE) AS 'DateOf',
(
SELECT COUNT(*)
FROM [DBName].[AppName].[ErrorLog] AS Tbl2
WHERE CAST(Tbl2.WhenOccurred AS DATE) = 'DateOf'
) AS [CountOf]
FROM [DBName].[AppName].[ErrorLog] AS MnTbl
WHERE [WhenOccurred] > '2/1/2023' AND UPPER([ErrorMessage]) LIKE '%TIMEOUT%'
I receive the following error…
Conversion failed when converting date and/or time from character string.