SQL Query, Bar Gauge, Count/Sum of Last 7 Days?

Hi All,

I am new to coding and am struggling with getting started on something. I have done a lot of searching and checked the documentation, however I think there is a concept I am missing with Time.
Details:

  • MSSQL
  • Creating a Bar Gauge
  • Format as Table
  • Trying to get a count and/or sum in some cases but for records from the last seven days. Date in the SQL table is named [date} and is in the format 2020-03-20.
  • Queries work in MSSQL SMS.

When I try these queries in Grafana, I get “No Data” message in the panel. If I remove the DATEADD portion, they work but get count/sum data for all time. I read the time macros section, but cannot make the connection. Appreciate any and all help.

SELECT
[businessName], COUNT (*) as Count
FROM [dbo].[deployment]
Where [status] = ‘completed’
AND [date] >= DATEADD(day,-7, GETDATE())
GROUP BY [businessName]

Another example:

SELECT
businessName,
SUM(memoryUtil) ‘Memory Utilized’
FROM
[Deployment].[dbo].[vmdeployment]
Where [status] = ‘completed’
AND [date] >= DATEADD(day,-7, GETDATE())
GROUP BY
businessName;

Thanks much.