Converting X axis along Time series Panel from time to date (YYYY-MM-DD) format

Hello fellow Grafaners. Could someone please help me out with the issue I’m currently facing? Also, please do let me know if more info is required on my side. Thank you so much in advance.

  • What Grafana version and what operating system are you using?
    I just installed Grafana like 3 days ago, literally, so I assume it’s the latest version available for Windows. Version is “Grafana v12.0.1 (80658a73c5)”. My OS is Windows 11.

  • What are you trying to achieve?
    My question is regarding Time Series Panel (not Bar chart, or anything else). I am trying to convert my time in the x-axis into YYYY-MM-DD format.

  • How are you trying to achieve it?
    My database is SQLite.
    I have the following query script under Queries:

SELECT
  strftime('%s', ls.Date) as time,  -- This becomes the X-axis (date timestamp)
  -- Convert 'Slept at' to seconds since midnight for numerical plotting on Y-axis
  (CAST(strftime('%H', ls.StartSleepTime) AS INTEGER) * 3600) +
  (CAST(strftime('%M', ls.StartSleepTime) AS INTEGER) * 60) +
  (CAST(strftime('%S', ls.StartSleepTime) AS INTEGER)) AS "Slept at (seconds from midnight)",

  -- Convert 'Awoke at' to seconds since midnight for numerical plotting on Y-axis
  (CAST(strftime('%H', ls.EndSleepTime) AS INTEGER) * 3600) +
  (CAST(strftime('%M', ls.EndSleepTime) AS INTEGER) * 60) +
  (CAST(strftime('%S', ls.EndSleepTime) AS INTEGER)) AS "Awoke at (seconds from midnight)",

  ls.TotalSleepHours as "Total sleep hours",
  ls.TotalSleepHours * 3600 as TotalSleepInSeconds,
  strftime('%d日', ls.Date) as DateLabel
FROM Sleep_Table ls
WHERE strftime('%Y-%m', Date) = strftime('%Y-%m', 'now');

My Date field in my SQLite database is just a text (even though I set it to Date data type in SQLite DB, SQLite doesn’t really have such a type, thus it’s being treated as a text type, correct me if I’m wrong on this part though) with the following sample data: “2025-06-19 00:00:00”. The time, which I have no intention in tracking for this Date field, always contains 00:00:00. Now, I just can’t simply use this field in Grafana’s Time series panel, since they’ll complain it’s not a proper time format field. Because of this, I’m forced to use strftime('%s', ls.Date) as time in my query. Someone please correct me on this if I’m doing this all wrong, or my approach is incorrect.

  • What happened?

    As you can see in the screenshot above, along the X axis is showing Time (date is being truncated away for god knows what reason it is).
    If I were to switch it to table view (still within Time series Panel), it’s showing the following:

    Now something I found it really weird, is that the original data, which is supposed to be 00:00:00, became 09:00:00. No idea why, but it’s happening.

I’ve attempted the following method:


But it’s still not working. Value still left unconverted

However, in the tooltip view, it’s correctly converted. You can see it right at the top “2025-06-19”, without showing the time, only the date:

  • What did you expect to happen?
    I expect time field to be converted, from date time into a date only field, being shown along the x-axis.
    Something like what others were able to achieve:
    Original source: Time series Unit

  • Did you follow any online instructions? If so, what is the URL?

    • http s://community.grafana.com/t/timeseries-x-axis-time-axis-complete-date-format/116564: (I was told that new users could only put two links in a new thread, so I’m trying to work around it by adding a space in this link here. When copy-pasting, please remove the whitespace in the link here.)
      Unsolved, same case like mine.

“I tried to solve your problem. This is not possible in the ‘time series panel’. You can do it using the ‘bar chart’ instead.”


Thanks for the quick reply, trying to help solving my issue!
Also, thanks for the suggestion of using Bar chart!
However, I would like to know, while others are able to perfectly pull off what I was trying to do, why am I not able to do it? What are my issues?
While bar chart can indeed solve my problem, seeing the chart will vastly differ from what I really wanted, in trying to compare the average of all 3 fields: SleepTime, WakeTime and TotalSleepTime.
Viewing it in bar chart can get very messy visually, without being able to see the clearly the difference. I hope I’ve gotten my points across.

Okay, I was being dumb all along. All I had to do, was to add the query time range and changed it to “This month” (located at the top right hand corner, next to “Refresh” button):

For other graphs/panels of mine, I did not utilize that range as I all did was hardcoding the time range into my sqlite script, so I did not realize this time range was the main culprit. Thanks infofcc3 for the help though :slight_smile: Highly appreciated for the assistance.

1 Like