Line chart does not display data correctly

  • What Grafana version and what operating system are you using?
    9.2.5, Windows 10

  • What are you trying to achieve?
    I am trying to show data on line chart.

  • What happened?
    I fetched the data with MSSQL datasource.
    The data appears correctly in the table view. But when I switch to chart view, the data changes. Showing data from about 3 hours ago.

The query i wrote;
query

Data returned from query;

The data shown in the chart.

The time at the point I showed with my mouse is 13:06:32, but there is another recording data at this time.

  • What did you expect to happen?
    I was expecting to visualize exactly the data appearing in the table view.

If your datetime field UTC? If not use some mssql function to convert your datetime field to UTC

I don’t know exactly what the UTC format is, but I keep the time as “YYYY-MM-DD hh:mm:ss:xxx” in the database.

Utc is a timezone not a format.
What do you see when you do

select getdate()

in ssms

when i run select getdate() from DataLogTest, it gives me “2022-11-22 17:44:25:803”

Current utc :point_up:

Grafana understands utc so you need to convert your date time column to utc using a sql server function

Sorry seems like I accidentally closed it.
check this out

SELECT DATEADD(second, DATEDIFF(second, GETDATE(), GETUTCDATE()), getdate());

This is one way you could do it by changing getdate to you date time column, try it our for testing purposes only. as the above does not take into account daylight savings time.

Then you should see the grafana time adjust properly

1 Like

Thank you very much, that solved my problem. I guess I’m using it in a production environment since there’s no daylight savings time in the area I live in.

1 Like