Grafana Datediff with Synapse Datasource

71 Views Asked by At

I have a simple query that works within Azure Synapse using its built-in MySql Server:

SELECT TOP (15)
  cast ("Betriebstag" as DATETIME),
  CONVERT (VARCHAR, "Betriebstag", 34) as "betriebstag",
  "MWNR",
  "kwhUsed" as "Ist-Verbrauch",
  "kWh_prediction" as "ML Prognose",
  "kwh_prediction_linear_temperature" as "Lineare Prognose",
  cast ("prediction_written" as DATETIME)
FROM [dbo].[XYZ]
WHERE ("Betriebstag" BETWEEN '2023-08-01' AND '2023-08-15') 
AND "MWNR" = 4021
AND DATEDIFF(day, "Betriebstag", "prediction_written") = -1 
AND kwhUsed is not null
ORDER BY "Betriebstag" asc

In Grafana I use the same database. However, using the same query I get an error:

convert frame from rows error: mssql: Conversion failed when converting date and/or time from character string.

Is there any difference in using DATEDIFF in Grafana? Or is there something wrong in casting my timestamp variables to DATETIME?

Thanks!

0

There are 0 best solutions below